https://www.acmicpc.net/problem/6131
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int int64_t
using namespace std;
int _pow(int x,int n){
int ret = 1;
while(n){
if(n & 1) ret *= x;
n >>= 1;
x *= x;
}
return ret;
}
int Sol(int n){
int ret = 0;
for(int a = 1; a <= 500; a++){
for(int b = 1; b <= 500; b++){
if(_pow(a, 2) == (_pow(b, 2) + n)) ret++;
}
}
return ret;
}
int32_t main() {
fastio;
int n; cin >> n;
cout << Sol(n) << "\n";
}
feat) 빠른 거듭제곱 알고리즘