Saleh127

UVA 962

Aug 29th, 2020 (edited)
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; while(t--)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. ll n,m,d,i,j,k,l;
  11.  
  12. while(cin>>n>>m)
  13. {
  14.  
  15. ll a[100500];
  16. map<ll,bool>c;
  17. d=cbrt(n+m)+1;
  18. l=k=0;
  19. for(i=1;i<=d;i++)
  20. {
  21. for(j=i+1;j<=d;j++)
  22. {
  23. ll s=(i*i*i)+(j*j*j);
  24. if(s>=n && s<=(n+m))
  25. {
  26. a[l]=s;
  27. l++;
  28. }
  29. }
  30. }
  31. sort(a,a+l);
  32. for(i=0;i<l-1;i++)
  33. {
  34. if(a[i]==a[i+1] && c[a[i]]==0)
  35. {
  36. cout<<a[i]<<endl;
  37. k=1;
  38. c[a[i]]=true;
  39. }
  40. }
  41. if(k==0) cout<<"None"<<endl;
  42. }
  43. return 0;
  44. }
  45.  
Add Comment
Please, Sign In to add comment