ural 1073. Square Country
1073. Square Country
Memory limit: 64 MB
Input
Output
Sample
input | output |
---|---|
344 |
3 |
Problem Source: Ural State Univerisity Personal Contest Online February'2001 Students Session
/**
Create By yzx - stupidboy
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef double DB;
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair inline int Getint()
{
int Ret = ;
char Ch = ' ';
bool Flag = ;
while(!(Ch >= '' && Ch <= ''))
{
if(Ch == '-') Flag ^= ;
Ch = getchar();
}
while(Ch >= '' && Ch <= '')
{
Ret = Ret * + Ch - '';
Ch = getchar();
}
return Flag ? -Ret : Ret;
} const int N = ;
int n;
int dp[N]; inline void Input()
{
cin >> n;
} inline void Solve()
{
dp[] = , dp[] = ;
for(int i = ; i <= n; i++)
{
dp[i] = INF;
for(int j = ; j <= i / j; j++)
if(dp[i] > dp[i - j * j] + )
dp[i] = dp[i - j * j] + ;
}
cout << dp[n] << endl;
} int main()
{
freopen("e.in", "r", stdin);
Input();
Solve();
return ;
}
ural 1073. Square Country的更多相关文章
- 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 1073 Square Country (DP)
题目地址:Ural 1073 DP水题.也能够说是背包. #include <iostream> #include <cstdio> #include <string&g ...
- URAL 1073 Square Country(DP)
题目链接 题意 :这个人要投资地,每块地都是正方形并且边长都是整数,他希望他要买的地尽量的少碎块.每买一块地要付的钱是边长的平方,而且会得到一个一份证书,给你一个钱数,让你求出能得到的证书个数. 思路 ...
- ural 1698. Square Country 5(记忆化搜索)
1698. Square Country 5 Time limit: 2.0 secondMemory limit: 64 MB The first arithmetical operation ta ...
- URAL 1097 Square Country 2 离散化
一共才100个正方形,将所有正方形左下角和右上角的X坐标和Y坐标离散化,直接枚举新建公园的点的坐标即可. O(n^3)的时间复杂度. #include <cstdio> #include ...
- URAL 1698. Square Country 5(记忆化搜索)
题目链接 题意 : 自守数的定义:如果某个数的平方的末尾几位数等于这个数,那么就称这个数为自守数.例如5*5=25,则5就是自守数.让你求不超过n位的自守数有多少 思路 : 实际上,自守数还有两个性质 ...
- ural1097 Square Country 2
Square Country 2 Time limit: 1.0 secondMemory limit: 64 MB The Square Parliament of the Square count ...
- Square Country
原题链接:http://acm.timus.ru/problem.aspx?space=1&num=1073 分析:dp,dp[i]表示钱为i且恰好用完时能买的最少土地数,易知dp[i]=mi ...
随机推荐
- C++异常层次结构图
- NYOJ题目842整除的尾数
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAsUAAAIMCAIAAACSTkYzAAAgAElEQVR4nO3dO3KjzBrG8bMJ5VqIYx ...
- hdu 1005
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1005 思路:找规律题 #include<stdio.h> main() { ]; int ...
- 三、jQuery--jQuery基础--jQuery基础课程--第4章 jQuery表单选择器
1.:input表单选择器 如何获取表单全部元素?:input表单选择器可以实现,它的功能是返回全部的表单元素,不仅包括所有<input>标记的表单元素,而且还包括<textarea ...
- Python读取xml报错解析--ExpatError: not well-formed (invalid token)
xml文件内容如代码所示存入的名字为login.xml: <?xml version="1.0" encoding="utf-8"?> <in ...
- Delphi的TThread中的FreeOnTerminate成员
类 Create 了就要 Free; 但 TThread(的子类) 有特殊性, 很多时候我们不能确定新建的线程什么时候执行完(也就是什么时候该释放); 如果线程执行完毕自己知道释放就好了, 所以 ...
- 【翻译十八】java-并发之锁对象
Lock Objects Synchronized code relies on a simple kind of reentrant lock. This kind of lock is easy ...
- python多线程之Condition(条件变量)
#!/usr/bin/env python # -*- coding: utf-8 -*- from threading import Thread, Condition import time it ...
- wp8 入门到精通 Animation 背景加字体颜色从下向上变化颜色效果
<phone:PhoneApplicationPage.Resources> <Style x:Key="ButtonStyle1" TargetType=&qu ...
- hdu 4050 2011北京赛区网络赛K 概率dp ***
题目:给出1-n连续的方格,从0开始,每一个格子有4个状态,左右脚交替,向右跳,而且每一步的步长必须在给定的区间之内.当跳出n个格子或者没有格子可以跳的时候就结束了,求出游戏的期望步数 0:表示不能到 ...