Ural 1073 Square Country (DP)
题目地址:Ural 1073
DP水题。也能够说是背包。
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm> using namespace std;
const int INF=0x3f3f3f3f;
#define LL long long
int dp[60006];
int main()
{
int i, j, n;
memset(dp,INF,sizeof(dp));
dp[0]=0;
for(i=1;i<250;i++)
{
for(j=i*i;j<=60000;j++)
{
dp[j]=min(dp[j],dp[j-i*i]+1);
}
}
while(scanf("%d",&n)!=EOF)
printf("%d\n",dp[n]);
return 0;
}
Ural 1073 Square Country (DP)的更多相关文章
- URAL 1073 Square Country(DP)
题目链接 题意 :这个人要投资地,每块地都是正方形并且边长都是整数,他希望他要买的地尽量的少碎块.每买一块地要付的钱是边长的平方,而且会得到一个一份证书,给你一个钱数,让你求出能得到的证书个数. 思路 ...
- ural 1073.Square Country(动态规划)
1073. Square Country Time limit: 1.0 secondMemory limit: 64 MB There live square people in a square ...
- 01背包 URAL 1073 Square Country
题目传送门 /* 题意:问n最少能是几个数的平方和 01背包:j*j的土地买不买的问题 详细解释:http://www.cnblogs.com/vongang/archive/2011/10/07/2 ...
- ural 1073. Square Country
1073. Square Country Time limit: 1.0 secondMemory limit: 64 MB There live square people in a square ...
- URAL 1146 Maximum Sum(DP)
Given a 2-dimensional array of positive and negative integers, find the sub-rectangle with the large ...
- URAL 1586 Threeprime Numbers(DP)
题目链接 题意 : 定义Threeprime为它的任意连续3位上的数字,都构成一个3位的质数. 求对于一个n位数,存在多少个Threeprime数. 思路 : 记录[100, 999]范围内所有素数( ...
- Ural 2018The Debut Album(DP)
题目地址:Ural 2018 简单DP.用滚动数组. 代码例如以下: #include <iostream> #include <cstdio> #include <st ...
- URAL 1183 Brackets Sequence(DP)
题目链接 题意 : 给你一串由括号组成的串,让你添加最少的括号使该串匹配. 思路 : 黑书上的DP.dp[i][j] = min{dp[i+1][j-1] (sh[i] == sh[j]),dp[i] ...
- URAL 1167. Bicolored Horses (DP)
题目链接 题意 :农夫每天都会放马出去,然后晚上把马赶入马厩,于是让马排成一行入马厩,但是不想马走更多的路,所以让前p1匹入第一个马厩,p2匹马入第二个马厩…………但是他不想让他的任何一个马厩空着,所 ...
随机推荐
- Java, C#, Swift语法对比速查表
原文:Java, C#, Swift语法对比速查表 Java 8 C# 6 Swift 变量 类型 变量名; 类型 变量名; var 变量名 : 类型; 变量(类型推断) N/A var 变量名= ...
- Deflater与Inflater的压缩与解压缩
原文:Deflater与Inflater的压缩与解压缩 package util; import java.util.Arrays; import java.util.zip.Deflater; im ...
- kingso_module - Taocode
kingso_module - Taocode 模块介绍 Merger 功能介绍 Merger的功能: 合并多台Searcher机器的部分查询结果,得到最终的完整查询结果 向Detail集群请求最终展 ...
- 青云B轮获2000万美元VC的背后逻辑:用技术超越巨头
http://www.lagou.com/gongsi/31164.html http://capital.chinaventure.com.cn/11/7/1389263145.shtml
- StrPos,StrScan,
Delphi提供的字符串函数里有一个Pos函数,它的定义是: function Pos(Substr: string; S: string): Integer; 它的作用是在字符串S中查找字符串Sub ...
- ETC_百度百科
ETC_百度百科 ETC(电子不停车收费系统)
- dfs-hdu-4620-Fruit Ninja Extreme
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4620 题目大意: 切水果.给n刀,每刀的时间,每刀切的水果的种类.求能切的最多的刀数,使得每相邻的两 ...
- 【linux kernel】 中断处理-中断下半部
欢迎转载,转载时需保留作者信息,谢谢. 邮箱:tangzhongp@163.com 博客园地址:http://www.cnblogs.com/embedded-tzp Csdn博客地址:http:// ...
- ios9 之后 配置百度地图出现的错误
链接地址:http://blog.csdn.net/u011303663/article/details/48596315 错误 ld: '/Users/xxx/Documents/xxx/Baidu ...
- 华为手机logcat不出日志解决方案
解决方法:在拨打电话界面,录入*#*#2846579#*#* 自动进入开发界面菜单,进入第一个,选择开启logcat.