Advertisement
royalsflush

ReferĂȘncia para UVa 256 (Luiza)

Apr 6th, 2012
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define sq(x) ((x)*(x))
  4. long long div;
  5. int dig;
  6.  
  7. int main() {
  8.     while (scanf("%d", &dig)!=EOF) {
  9.         div=1;
  10.         for (int i=0; i<dig/2; i++)
  11.             div*=10;
  12.  
  13.         for (long long a=0; a<div*10; a++) {
  14.             if (sq(a)>=sq(div)) break;
  15.             long long p1 = sq(a)/div;
  16.             long long p2 = sq(a)%div;
  17.  
  18.             if (sq(p1+p2)==sq(a)) printf("%0*lld\n",dig,sq(a));
  19.         }
  20.     }
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement