Advertisement
Farjana_akter

Untitled

Feb 1st, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. long long int arr[1000000],j;
  6. void div(long long int n)
  7. {
  8. j=0;
  9. for(int i=1; i<=sqrt(n); i++)
  10. {
  11. if(n%i==0)
  12. {
  13. arr[j++]=i;
  14. if(n/i!=i)
  15. arr[j++]=n/i;
  16. }
  17. }
  18. }
  19.  
  20. int main()
  21. {
  22. long long int p,l,i,k,n,q,t,cas;
  23. cin>>t;
  24. for(cas=1; cas<=t; cas++)
  25. {
  26. cin>>p>>l;
  27. q=p-l;
  28. cout<<"Case "<<cas<<":";
  29. if(q<=l)
  30. {
  31. cout<<" impossible"<<endl;
  32. continue;
  33. }
  34. else
  35. {
  36. div(q);
  37. sort(arr,arr+j);
  38. long long int pos=0,flag=0;
  39. for(i=pos; i<j; i++)
  40. {
  41. if(arr[i]<=l)
  42. continue;
  43. cout<<" "<<arr[i];
  44. }
  45. cout<<endl;
  46. }
  47. }
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement