CDOJ--1404
原题链接:http://acm.uestc.edu.cn/problem.php?pid=1404
分析:定义dp[i][j]表示i位时最左边为j时的情况,那么dp[i][[j]可以由dp[i-1][k](k>=j)得到。
Non-Decreasing Digits
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define maxn 100005
#define ll long long
using namespace std;
ll dp[70][12];
void solve()
{
for(int i=0;i<=9;i++)dp[1][i]=1;
for(int i=2;i<=64;i++)
{
ll sum=0;
for(int j=9;j>=0;j--)
{
dp[i][j]=sum+dp[i-1][j];
sum+=dp[i-1][j];
}
}
}
int main()
{
int P;
solve();
scanf("%d",&P);
while(P--)
{
int cas,n;
scanf("%d%d",&cas,&n);
ll ans=0;
for(int i=0;i<=9;i++)
ans+=dp[n][i];
printf("%d %lld\n",cas,ans);
}
return 0;
}
CDOJ--1404的更多相关文章
- cdoj 1489 老司机采花
地址:http://acm.uestc.edu.cn/#/problem/show/1489 题目: 老司机采花 Time Limit: 3000/1000MS (Java/Others) M ...
- hdu 1404 找sg ***
HDU 1404 Digital Deletions 一串由0~9组成的数字,可以进行两个操作:1.把其中一个数变为比它小的数:2.把其中一个数字0及其右边的所以数字删除. 两人轮流进行操作,最后把 ...
- hdoj 1404 Digital Deletions(博弈论)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1404 一看就是博弈论的题目,但并没有什么思路,看了题解,才明白 就是求六位数的SG函数,暴力一遍,打表 ...
- POJ 1404 I-Keyboard (DP)
http://poj.org/problem?id=1404 题意 :手机上的要发短信的话,“我”字需要先按一下9键,再按3下6键,所以,现在想要重新布局每个键上的字母数,让最后的那个值最小,也就是说 ...
- Hdu 1404 Digital Deletions
Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1404 刚开始想采取找规律的方法解题,可以没有发现规律.无奈,只好采用求PN点的方法. 我们假 ...
- bash no such file or directory in ubuntu 1404
我在我的今天macbook pro retina 里面安装的虚拟机ubuntu 1404. 当我试图执行cadence ncverilog时间.ubuntu终端错误"bash no such ...
- URAL 1404. Easy to Hack! (模拟)
space=1&num=1404">1404. Easy to Hack! Time limit: 1.0 second Memory limit: 64 MB When Vi ...
- Vijos 1404 遭遇战
Vijos 1404 遭遇战 背景 你知道吗,SQ Class的人都很喜欢打CS.(不知道CS是什么的人不用参加这次比赛). 描述 今天,他们在打一张叫DUSTII的地图,万恶的恐怖分子要炸掉藏在A区 ...
- Vijos 1404 遭遇战 - 动态规划 - 线段树 - 最短路 - 堆
背景 你知道吗,SQ Class的人都很喜欢打CS.(不知道CS是什么的人不用参加这次比赛). 描述 今天,他们在打一张叫DUSTII的地图,万恶的恐怖分子要炸掉藏在A区的SQC论坛服务器!我们SQC ...
- CDOJ 1324 卿学姐与公主(分块)
CDOJ 1324 卿学姐与公主(分块) 传送门: UESTC Online Judgehttp://acm.uestc.edu.cn/#/problem/show/1324 某日,百无聊赖的卿学姐打 ...
随机推荐
- 【python 2.7】python读取json数据存入MySQL
同上一篇,只是适配 CentOS+ python 2.7 #python 2.7 # -*- coding:utf-8 -*- __author__ = 'BH8ANK' import json im ...
- .net mvc5 不同view()的视图 代码
public class Test { public int id { set; get; } public string name { set; get; } } public ActionResu ...
- 微软职位内部推荐-Software Engineer II_HPC
微软近期Open的职位: Job Title: Software Engineer II_HPC Location: Shanghai, China Are you passionate about ...
- [C++] Solve "No source available for main()" error when debugging on Eclipse
In Mac, the issue image: 1. A existing cmake project on disk 2. import this project into Eclipse. 3 ...
- Segments CodeForces 909B (找规律)
Description You are given an integer N. Consider all possible segments (线段,划分)on the coordinate axis ...
- 第九周个人PSP
11.10--11.16本周例行报告 1.PSP(personal software process )个人软件过程. C(类别) C(内容) ST(开始时间) ET(结束时间) INT(间隔时间) ...
- HDU 5200 Trees 二分
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5200 bc(中文):http://bestcoder.hdu.edu.cn/contests ...
- 【leetcode】59.Spiral Matrix II
Leetcode59 Spiral Matrix II Given an integer n, generate a square matrix filled with elements from 1 ...
- 什么是HotSpot
Java 是动态编译,跟C++静态编译不同,这就是JIT编译器的原因(Just In Time) HotSpot会把这些部门动态地编译成机器码,Native code, 并对机器码进行优化, 静态编译 ...
- 常用yum源
#epel源 [myepel] name=zheda baseurl=http://mirrors.zju.edu.cn/epel/6/x86_64/ gpgcheck= enabled= #mysq ...