Hdu1407 test whether your level is as high as that of LTC

Source: Internet
Author: User
Test whether you are as high as the LTC level

Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 10283 accepted submission (s): 3325

Problem description we all admire LTC. However, if you only have this question in the competition, I am sure you are definitely on a horizontal line with him!
Your task is:
Returns a positive integer of x ^ 2 + y ^ 2 + Z ^ 2 = num.

The input data contains multiple test instances. Each instance occupies one row and only contains a positive integer num less than or equal to 10000.

Output: for each group of test data, please output a minimum positive integer solution in the ascending order of X, Y, and Z. The output of each instance occupies one line. The question ensures that all test data is parsed.

Sample Input

 
3

Sample output

 
1 1 1

Authorlcy

Source hangdian ACM training team training competition (IV)
 

Recommendignatius. L

Solution: No need to use special questionsAlgorithm, Directly compare the three nested loops one by one.

# Include <stdio. h> # include <math. h> int main () {int I, j, k; int m; while (scanf ("% d", & M )! = EOF) {int f = 0; int n = SQRT (m); for (I = 1; I <= N; I ++) // compare {for (j = I; j <= N; j ++) {for (k = J; k <= N; k ++) {if (I * I + J * j + K * k = m) {f = 1; break;} If (f) break;} printf ("% d \ n", I, j, k);} return 0 ;}

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.