Hangzhou Electric HDU ACM 1407 test If you are as high as the LTC level

Source: Internet
Author: User

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

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.