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 ;}