题目传送门

 /*
题意:1~1e9的数字里,各个位数数字相加和为s的个数
递推DP:dp[i][j] 表示i位数字,当前数字和为j的个数
状态转移方程:dp[i][j] += dp[i-1][j-k],为了不出现负数
改为:dp[i][j+k] += dp[i-1][j]
*/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std; const int MAXN = 1e4 + ;
const int INF = 0x3f3f3f3f;
int dp[][]; int main(void) //URAL 1353 Milliard Vasya's Function
{
//freopen ("F.in", "r", stdin); int s;
while (scanf ("%d", &s) == )
{
memset (dp, , sizeof (dp)); dp[][] = ;
for (int i=; i<=; ++i)
{
for (int j=; j<=s; ++j)
{
if (dp[i-][j])
{
for (int k=; k<=; ++k) dp[i][j+k] += dp[i-][j];
} }
} if (s == ) dp[][s] += ;
printf ("%d\n", dp[][s]);
} return ;
}

递推DP URAL 1353 Milliard Vasya's Function的更多相关文章

  1. ural 1353. Milliard Vasya's Function(dp)

    1353. Milliard Vasya's Function Time limit: 1.0 second Memory limit: 64 MB Vasya is the beginning ma ...

  2. ural 1353. Milliard Vasya's Function(背包/递归深搜)

    1353. Milliard Vasya's Function Time limit: 1.0 second Memory limit: 64 MB Vasya is the beginning ma ...

  3. URAL 1353 Milliard Vasya's Function(DP)

    题目链接 题意 : 让你找出1到10^9中和为s的数有多少个. 思路 : 自己没想出来,看的题解,学长的题解报告 题解报告 //URAL 1353 #include <iostream> ...

  4. ural 1353. Milliard Vasya's Function

    http://acm.timus.ru/problem.aspx?space=1&num=1353 #include <cstdio> #include <cstring&g ...

  5. 递推DP URAL 1017 Staircases

    题目传送门 /* 题意:给n块砖头,问能组成多少个楼梯,楼梯至少两层,且每层至少一块砖头,层与层之间数目不能相等! 递推DP:dp[i][j] 表示总共i块砖头,最后一列的砖头数是j块的方案数 状态转 ...

  6. 递推DP URAL 1260 Nudnik Photographer

    题目传送门 /* 递推DP: dp[i] 表示放i的方案数,最后累加前n-2的数字的方案数 */ #include <cstdio> #include <algorithm> ...

  7. 递推DP URAL 1119 Metro

    题目传送门 /* 题意:已知起点(1,1),终点(n,m):从一个点水平或垂直走到相邻的点距离+1,还有k个抄近道的对角线+sqrt (2.0): 递推DP:仿照JayYe,处理的很巧妙,学习:) 好 ...

  8. 递推DP URAL 1031 Railway Tickets

    题目传送门 /* 简单递推DP:读题烦!在区间内的都更新一遍,dp[]初始化INF 注意:s1与s2大小不一定,坑! 详细解释:http://blog.csdn.net/kk303/article/d ...

  9. 递推DP URAL 1167 Bicolored Horses

    题目传送门 题意:k个马棚,n条马,黑马1, 白马0,每个马棚unhappy指数:黑马数*白马数,问最小的unhappy值是多少分析:dp[i][j] 表示第i个马棚放j只马的最小unhappy值,状 ...

随机推荐

  1. TASKKILL命令使用大全

    Mr.Savin Mr.Savin 2009-08-07 183315TASKKILL [S system [U username [P [password]] { [FI filter] [PID ...

  2. 第8章 Iptables与Firewalld防火墙

    章节简述: 红帽RHEL7系统已经用firewalld服务替代了iptables服务,新的防火墙管理命令firewall-cmd与图形化工具firewall-config. 本章节基于数十个防火墙需求 ...

  3. $gte 必须使用双引号,且冒号后面不能有空格

    pry(main)> puts "showlastupdate:{\"$gte\":\"#{Date.today.to_s(:number)}\" ...

  4. 纯Java获得本地MAC地址

    import java.net.*; public class Ipconfig{      public static void main(String[] arguments) throws Ex ...

  5. Javascript样例之文档章节滚动全版(DOM)

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABBMAAAC5CAIAAAD1bOCRAAAMEUlEQVR4nO3d4XEbyREGUGRCZQDGcG

  6. [BZOJ]1016 JSOI2008 最小生成树计数

    最小生成树计数 题目描述 现在给出了一个简单无向加权图.你不满足于求出这个图的最小生成树,而希望知道这个图中有多少个不同的最小生成树.(如果两颗最小生成树中至少有一条边不同,则这两个最小生成树就是不同 ...

  7. mysql如何用order by 自定义排序

    mysql如何用order by 自定义排序 id name roleId aaa bbb ccc ddd eee ,MySQL可以通过field()函数自定义排序,格式:field(value,st ...

  8. 什么是mixin

    转自:http://guangboo.org/2013/01/28/python-mixin-programming http://en.wikipedia.org/wiki/Mixin http:/ ...

  9. Resumable Media Uploads in the Google Data Protocol

    Eric Bidelman, Google Apps APIs team February 2010 Introduction The Resumable Protocol Initiating a ...

  10. Python DBUtils

    1 简介 DBUtils是一套Python数据库连接池包,并允许对非线程安全的数据库接口进行线程安全包装.DBUtils来自Webware for Python. DBUtils提供两种外部接口: P ...