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