Test if you are as high as the LTC level problem description Everybody mentions that LTC all admire not, but if the contest has only this one topic, I can assure 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 INPUT3 Sample OUTPUT1 1 1 Answer the topic requires a positive integer solution, so the number of cycles can not start from 0, otherwise 49 (2 3 6) this will WA. Use the function return to facilitate the point.
#include <cstdio>#include<iostream>#include<string>#include<sstream>#include<cstring>#include<stack>#include<queue>#include<algorithm>#include<cmath>#include<map>#definePI ACOs (-1.0)#defineMS (a) memset (A,0,sizeof (a))#defineMSP Memset (Mp,0,sizeof (MP))#defineMSV memset (vis,0,sizeof (VIS))using namespacestd;//#define LOCALvoidFunintnum) { for(intx=1; x<= -; x + +) for(inty=1; y<= -; y++) for(intz=1; z<= -; z++) if(x*x+y*y+z*z==num) {printf ("%d%d%d\n", x, y, z);return;}}intMain () {#ifdef LOCAL freopen ("In.txt","R", stdin);#endif //LOCALIos::sync_with_stdio (false); intnum; while(cin>>num) fun (num); return 0;}
View Code
HDU 1407 Test If you are as high as the LTC level (enumeration)