Test if 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): 14276 Accepted Submission (s): 4701
Problem description Everybody mentions LTC all admire not, however, if the contest only this one topic, I can guarantee you and he absolutely on a horizontal line!
Your mission is to:
A positive integer solution of x^2+y^2+z^2= num for the computational equation.
Input data contains multiple test instances, one row per instance, and only a positive integer num of less than or equal to 10000.
Output for each set of test data, export one of its smallest positive integer solutions in the order of x, Y, z increments, with the output of each instance having a row, and the title guarantees that all test data will have a solution.
Sample Input
3
Sample Output
1 1 1
Authorlcy
SOURCE Hangzhou Electric ACM Training Team Training Tournament (IV)
#include <iostream>using namespace Std;int main () {int Num,i,j,k;loop:while (cin>>num) {for (i=1;i*i<num ; i++) for (k=1;k*k<=num-i*i;k++) for (j=1;j*j<=num-i*i-k*k;j++) if ((i*i+k*k+j*j) ==num) {cout<<i<< " "<<k<<" "<<j<<endl;goto Loop;}} return 0;}
Hangzhou Electric HDU ACM 1407 test If you are as high as the LTC level