Advertisement
smsnobin77

11428 - Cubes_2

Feb 26th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     int n, i, j,k,flag;
  5.  
  6.     while (scanf("%d", &n)==1)
  7.     {   if(n==0)
  8.             break;
  9.         flag=0;
  10.         for(i=1; i<60; i++)
  11.         {
  12.             for(j=0; j<=i; j++)
  13.             {
  14.                 if(n==(i*i*i-j*j*j))
  15.                 {
  16.                     flag=1;
  17.                     break;
  18.                 }
  19.             }
  20.             if(flag==1)
  21.             break;
  22.         }
  23.        if(flag==1) printf("%d %d\n",i, j);
  24.        else
  25.         printf("No solution\n");
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement