题意: 找出符合公式条件的个数
思路: 暴力枚举z, 二分对于当前的x , y的可能是否存在
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
typedef long long ll;
using namespace std;
ll pow2(ll a, ll b)
{
ll k = 1;
for(ll i=1; i<=b; ++i)
k *= a;
return k;
}
int main (void)
{
ios::sync_with_stdio(false);
ll k;
while(cin>>k, k)
{
ll ans = 0;
for(ll z=2; z<=32; ++z)
{
ll ed = pow(2147483647/2, 1.0/z) + 0.5;
for(ll x=1; x<=ed; ++x)
{
ll l = x+1, r = ed*2, mid;
while(l <= r)
{
mid = (l+r) >> 1;
if(pow2(x, z) + pow2(mid, z) + x*mid*z == k)
{
ans ++ ;
break;
}
else if(pow2(x, z) + pow2(mid, z) + x*mid*z < k)
l = mid+1;
else
r = mid-1;
}
}
}
cout<<ans<<endl;
}
return 0;
}