hdu4282 A very hard mathematic pro
发布时间: 2012-09-19 13:43:53 作者: rapoo
hdu4282 A very hard mathematic problem-----天津网络赛
A very hard mathematic problemTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 913 Accepted Submission(s): 268
Problem DescriptionInputOutputSample InputSample OutputSourceRecommend#include<iostream>#include<cstdlib>#include<stdio.h>#include<math.h>using namespace std;#define ll __int64ll power(ll x,int y){ ll temp=x; for(int i=2;i<=y;i++) temp*=x; return temp;}int main(){ ll n; while(scanf("%I64d",&n)&&n) { int ans=0; int temp=sqrt(n); if(temp*temp==n) ans+=(temp-1)/2; for(int i=3;i<31;i++)//z { for(ll j=1;;j++) { ll y=power(j,i); if(y>=n/2) break; for(ll k=j+1;;k++)//先枚举小的 { ll x=power(k,i); ll uu=x+y+i*j*k; if(uu>n) break; else if(uu==n){ans++;break;} } } } cout<<ans<<endl; }}