hdu4282A very hard mathematic problem

http://acm.hdu.edu.cn/showproblem.php?pid=4282

仔细想这个题的时候 不到一小时了 开始写的时候也就还剩半个小时了 实验室开始很乱 打的也很乱 交了几次CE WA TLE之后 就放弃了

也是一道水题 了z为2时是完全平方 z从3开始枚举

View Code
 1 #include <iostream>
 2 #include<cstdio>
 3 #include<string.h>
 4 #include<math.h>
 5 using namespace std;
 6 __int64 pows(int x,int n)
 7  {
 8      int i;
 9      __int64 tem = 1;
10      for(i = 0; i < n; i++)
11      tem *= x;
12      return tem;
13  }
14 int main()
15 {
16     int i,j,y,dd,h;
17     __int64 k,s;
18     while(scanf("%I64d", &k)&&k)
19     {
20         s = 0;
21         int x = sqrt(k*1.0);
22         if(x*x==k&&k>=9)
23         {
24             if(x%2==0)
25             s+=x/2-1;
26             else
27             s+=x/2;
28         }
29         for(i = 3; i < 31 ; i++)
30         {
31             for(j = 1; ; j++)
32             {
33                 __int64 u = pows(j,i);
34                 if(u>=k/2)
35                 break;
36                 for(h = j+1 ; ; h++)
37                 {
38                     __int64 v = pows(h,i);
39                    if(u+v+i*j*h==k)
40                    s++;
41                    if(u+v+i*j*h>k)
42                    break;
43                 }
44             }
45         }
46         printf("%I64d\n",s);
47     }
48     return 0;
49 }
原文地址:https://www.cnblogs.com/shangyu/p/2679242.html