原题链接: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;
}

最新文章

  1. .NET Framework(.config)的配置文件架构
  2. LeetCode 371. Sum of Two Integers
  3. lighttpd配置
  4. Libevent 定时器
  5. 单点登录系统构建之一——基础知识(Kerberous/SAML)
  6. 编译dubbo2.5.4时遇到的问题及解决
  7. MySql配置参数很全的Mysql配置参数说明
  8. ffmpeg+SDl+ 播放器 -01
  9. 不管ACM是不是屠龙之技
  10. js 里面 写 C# 代码 遇到的问题
  11. 简单的jquery实现tab切换
  12. c++ 如何获取多线程的返回值?
  13. Mock Server文章链接
  14. CountDownLatch简介
  15. Python中4位1进制数与float浮点数互相转换
  16. 【EMV L2】2CS.001.00 ~ 2CS.007.00
  17. Shell 脚本获取当前目录 和 获得 文件夹名
  18. Python全栈-magedu-2018-笔记11
  19. Eclipse Mars 2安装Drools6.4插件(Drools and jBPM tools)时无法安装JBoss Runtime Drools Detector
  20. 转: git使用时让http记住帐号密码

热门文章

  1. POJ-2018(二分)
  2. ES6的新特性(8)——数组的扩展
  3. JS加密库
  4. 扩展Lucas定理 扩展Lucas板子
  5. 福大软工1816:Beta总结
  6. nginx 简介  http://nginx.org
  7. spring重定向与转发
  8. 3dContactPointAnnotationTool开发日志(三二)
  9. ant 安装及基础教程 !
  10. (五)Jmeter中的属性和变量