URAL 1073 Square Country(DP)
题意 :这个人要投资地,每块地都是正方形并且边长都是整数,他希望他要买的地尽量的少碎块。每买一块地要付的钱是边长的平方,而且会得到一个一份证书,给你一个钱数,让你求出能得到的证书个数。
思路 :其实就是求x12+x22+……+Xn2中的最小的n。
//
#include <stdio.h>
#include <iostream>
#include <math.h> using namespace std ; int a[] ; void dp()
{
for(int i = ; i <= ; i++)
a[i] = ;
a[] = ;
for(int i = ; i <= ;i++)
{
for(int j = ; j <= (int)sqrt(i) ; j++)
a[i] = min(a[i],a[i-j*j]+ );
}
}
int main()
{
int n ;
dp() ;
scanf("%d",&n) ;
printf("%d\n",a[n]) ;
return ;
}
URAL 1073 Square Country(DP)的更多相关文章
- Ural 1073 Square Country (DP)
题目地址:Ural 1073 DP水题.也能够说是背包. #include <iostream> #include <cstdio> #include <string&g ...
- 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匹马入第二个马厩…………但是他不想让他的任何一个马厩空着,所 ...
随机推荐
- linux kernel with param
Linux kernel support pass param to kernel, this params can be assigned at load time by insmod or mod ...
- ABAP OO与ALV结合方式探索(2)
接上篇 一开始设计的BO 类是为了实现功能而实现功能 从类的单一职责的角度而言 先把这个BO对象拆分 这里又有一个需要考虑的点: 如何传递内表数据到ALV 如果引入一个中间变量,数据就会被do ...
- 使用JDBC向数据库中插入一条数据
原谅我是初学者,这个方法写的很烂,以后不会改进,谢谢 /** * 通过JDBC向数据库中插入一条数据 1.Statement 用于执行SQL语句的对象 1.1 通过Connection 的 * cre ...
- OpenDaylight之openflowjava的编译
最近因为工作需要开始研究opendaylight,首先需要的是编译项目. 因为项目代码都是在git.opendaylight.org上的,所以需要先安装git工具. 另因为opendaylight项目 ...
- linux 关机方式
linux 关机命令: 1- init 0 关机. 具体详情接受可以 init --help 查询 如下: init [OPTIONS...] {COMMAND} Send control comm ...
- 30个HTML5学习资源
早在几个星期前,Adobe就发布了Dreamweaver CS5 HTML5 Pack的预览版下载.众所周知,HTML5在互联网领域掀起了一场大论战,并让Adobe的日子很难熬.HTML5致力于为前端 ...
- [大牛翻译系列]Hadoop(20)附录A.10 压缩格式LZOP编译安装配置
附录A.10 LZOP LZOP是一种压缩解码器,在MapReduce中可以支持可分块的压缩.第5章中有一节介绍了如何应用LZOP.在这一节中,将介绍如何编译LZOP,在集群做相应配置. A.10.1 ...
- How to force to Fullscreen Form
Is it possibile by code resize a form to fullscreen? (like button Maximize) ? // VAR Changed on 10 J ...
- Cisco IOS Basic CLI Configuration:Access Security 01
1. Telnet Switch Config: Switch>en Switch#conf t Enter configuration commands, one per line. En ...
- JAVA的字节码技术
1.什么是字节码? 字节码 byteCode JVM能够解释执行的.java程序的归宿,但是从规范上来讲和Java已没有任何关系了.一些动态语言也可以编译成字节码在JVM上运行.字节码就相当于JVM上 ...