Advertisement
SSemen

Untitled

Nov 1st, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<stdio.h>
  3. #include<cmath>
  4.  
  5.  
  6. int main() {
  7.     long long n;
  8.     scanf("%lld", &n);
  9.     int a = sqrt(n);
  10.     long long  L, L1;
  11.     for (int i = 1; i < a; i++) {
  12.         for (int j = a; j >= i; j--) {
  13.             L = i * i + j * j;
  14.             L1 = (i + 1) * (i + 1) + j * j;
  15.             if (L < n) {
  16.                 if (L1 > n && (j != a && j != a - 1)) {
  17.                     printf("NO");
  18.                     return 0;
  19.                 }
  20.                 break;
  21.             }
  22.             else if (i == j && L > n) {
  23.                 printf("NO");
  24.                 return 0;
  25.             }
  26.             else if (L == n) {
  27.                 printf("YES\n%d %d", i, j);
  28.                 return 0;
  29.             }
  30.         }
  31.     }
  32.     printf("NO");
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement