[恢]hdu 1407
生活随笔
收集整理的這篇文章主要介紹了
[恢]hdu 1407
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2011-12-20 15:23:47
地址:http://acm.hdu.edu.cn/showproblem.php?pid=1407
題意:中文。
mark:TLE了幾次,沒想清楚循環上界。
代碼:
# include <stdio.h># include <math.h>
void gao(int num)
{
int x, y, z ;
int lim1 = sqrt(num),lim2 ;
for (x = 1 ; x <= lim1+1 ; x++)
{
lim2 = sqrt(num-x*x) ;
for (y = x ; y <= lim2 ; y++)
{
z = sqrt(num-x*x-y*y) ;
if (z == 0) continue ;
if (x*x + y*y+z*z == num)
{
printf ("%d %d %d\n", x, y, z) ;
return ;
}
}
}
}
int main ()
{
int num ;
while (~scanf ("%d", &num))
gao(num) ;
return 0 ;
}
轉載于:https://www.cnblogs.com/lzsz1212/archive/2012/01/06/2315295.html
總結
以上是生活随笔為你收集整理的[恢]hdu 1407的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 美媒发问:没有中国参与 世界能制造电动汽
- 下一篇: Adobe 引入自动标记功能,帮助残障人