Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include<stdio.h>
- #include<cmath>
- int main() {
- long long n;
- scanf("%lld", &n);
- int a = sqrt(n);
- long long L, L1;
- for (int i = 1; i < a; i++) {
- for (int j = a; j >= i; j--) {
- L = i * i + j * j;
- L1 = (i + 1) * (i + 1) + j * j;
- if (L < n) {
- if (L1 > n && (j != a && j != a - 1)) {
- printf("NO");
- return 0;
- }
- break;
- }
- else if (i == j && L > n) {
- printf("NO");
- return 0;
- }
- else if (L == n) {
- printf("YES\n%d %d", i, j);
- return 0;
- }
- }
- }
- printf("NO");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement