Advertisement
GeeckoDev

pe66

Aug 18th, 2011
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main()
  5. {
  6.   int d, x, y, sx, sy, fx, fy, max = 0;
  7.  
  8.   for (d=100; d<=1000; d++)
  9.   {
  10.     if (sqrtf(d) == (int)sqrtf(d)) continue;
  11.    
  12.     for (x=1, sx=1;; x++)
  13.     {
  14.       sx = x*x;
  15.      
  16.       for (y=1, sy=1; sx > d*sy+1; y++)
  17.       {
  18.         sy = y*y;
  19.         if (sx - d*sy == 1) break;
  20.       }  
  21.      
  22.       if (sx - d*sy == 1)
  23.       {
  24.         fx = x, fy = y;
  25.         if (fx > max) max = fx;
  26.         printf("%d^2 - %d*%d^2 = 1\n",fx,d,fy);
  27.         break;
  28.       }
  29.     }
  30.   }
  31.  
  32.   printf("max=%d\n",max);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement