Question:
IfCodeError. Please note
X ^ Z + y ^ Z + XYZ = K
K (0 <k <2 ^ 31), (x <y, z> 1)
Analysis:
Note that the maximum value of Z is 30 (x <y so y> = 2)
When K = 2, it can be determined by using the full square formula, which can be changed to (x + y) ^ 2 = K.
When K> 2, the values of Z, X, and y can be enumerated directly (when z> 2, the maximum value of X is About 1290)
| 6726850 |
2012-09-09 17:12:22 |
Accepted |
4282 |
281 Ms |
472 K |
1151 B |
G ++ |
View code
1 # Include <iostream> 2 # Include <cstdio>3 # Include <cmath> 4 5 Using Namespace STD; 6 7 Long Long Pow ( Long Long X, Int Z ){ 8 Long Long Temp = X; 9 For ( Int I = 2 ; I <= z; I ++ ) 10 X * = Temp; 11 Return X; 12 } 13 14 Int Main (){ 15 Freopen ( " Sum. In " , " R " , Stdin ); 16 Int N; 17 While (CIN> N, N ){ 18 Int Ans = 0 ; 19 Int Temp = SQRT (N ); 20 If (Temp * temp = N) 21 Ans + = (temp- 1 )> 1 ; 22 23 For ( Int Z = 3 ; Z < 31 ; Z ++ ){ 24 For ( Long Long X = 1 ; X ++ ){ 25 Long Long U = Pow (x, z ); 26 If (U> = N/ 2 ) 27 Break ; 28 For ( Long Long Y = x + 1 ; Y ++ ){ 29 Long Long V = Pow (Y, Z ); 30 If (U + V + z * x * Y> N) 31 Break ; 32 Else If (U + V + z * x * Y = N ){ 33 Ans ++ ; 34 Break ; 35 } 36 } 37 } 38 } 39 Cout <ans < Endl; 40 } 41 Return 0 ; 42 }