Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include<cstdio>
  2. #include<cmath>
  3. #include<map>
  4. #include<algorithm>
  5. #define MAX 1012
  6. using namespace std;
  7. map<int,int>mymap;
  8. int store[50000];
  9. int main()
  10. {
  11.    
  12.     int i,j,c=0;
  13.     for(i=1;i<=MAX;i++)
  14.      for(j=i;j<=MAX;j++)
  15.       {
  16.           int Icube=i*i*i;
  17.           int Jcube=j*j*j;
  18.           int sum=Icube+Jcube;
  19.          
  20.           if(mymap[sum]) {store[c++]=sum;}
  21.           else mymap[sum]=1;
  22.          
  23.          
  24.       }
  25.    
  26.  
  27.     sort(store,store+c);
  28.    
  29.     int up,low;
  30.     while(scanf("%d%d",&low,&up)==2)
  31.     {
  32.        
  33.                
  34.           up=up+low;
  35.        
  36.         for(i=0;i<c;i++)
  37.         {
  38.         if(store[i]>up) break;
  39.         if(store[i]>=low)
  40.         printf("%d\n",store[i]);
  41.         }
  42.        
  43.     }
  44.    
  45.    
  46.    
  47.    
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement