HDU 1407 Test If you are as high as the LTC level (enumeration)

Source: Internet
Author: User
Tags define local

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)

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.