HDU 4282 a very hard mathematic problem

Source: Internet
Author: User

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 }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.