首页 > 其他 > 详细

ural 1073. Square Country

时间:2014-03-31 10:39:32      阅读:525      评论:0      收藏:0      [点我收藏+]

http://acm.timus.ru/problem.aspx?space=1&num=1073

bubuko.com,布布扣
bubuko.com,布布扣
 1 #include <cstdio>
 2 #include <cstring>
 3 #include <cmath>
 4 #include <algorithm>
 5 #define maxn 70000
 6 using namespace std;
 7 const int inf=99999999;
 8 int dp[maxn];
 9 int main()
10 {
11     int n;
12     scanf("%d",&n);
13     for(int i=1; i<=n; i++)
14     {
15         dp[i]=inf;
16     }
17     dp[1]=1;
18     for(int i=2; i<=n; i++)
19     {
20         int k=(int)sqrt((double)i);
21         for(int j=0; j<=k; j++)
22         {
23             dp[i]=min(dp[i],dp[i-j*j]+1);
24         }
25     }
26     printf("%d\n",dp[n]);
27     return 0;
28 }
View Code
bubuko.com,布布扣

ural 1073. Square Country,布布扣,bubuko.com

ural 1073. Square Country

原文:http://www.cnblogs.com/fanminghui/p/3634403.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!