Advertisement
Saleh127

Untitled

May 3rd, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. int main()
  5. {
  6. ll t,p,l,c,d,e,f,i,j,k,q;
  7. scanf("%lld",&t);
  8. for(k=1; k<=t; k++)
  9. {
  10. cin>>p>>l;
  11. c=p-l;
  12. vector<ll>a;
  13. for(i=1; i*i<=c; i++)
  14. {
  15. if(c%i==0)
  16. {
  17. if(c/i!=i)
  18. {
  19. if(c/i>l)
  20. a.push_back(c/i);
  21. if(i>l)
  22. a.push_back(i);
  23. }
  24. else if(i>l)
  25. a.push_back(i);
  26. }
  27. }
  28. if(a.size()==0)
  29. printf("Case %lld: impossible\n",k);
  30. else
  31. {
  32. sort(a.begin(),a.end());
  33. printf("Case %lld: ",k);
  34. for(j=0; j<a.size(); j++)
  35. {
  36. if(j<a.size()-1)
  37. printf("%lld ",a[j]);
  38. else
  39. printf("%lld\n",a[j]);
  40. }
  41. }
  42. }
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement