Skill

时间:2023-03-09 17:48:27
Skill

Skill

Yasser is an Egyptian coach; he will be organizing a training camp in Jordan. At the end of camp,
Yasser was quiet amazed that the participants solved all of the hard problems he had prepared; so he
decided to give them one last challenge:

Print the number of integers having N digits where the digits form a non decreasing sequence.

Input Specification
Input will start with T <= 100 number of test cases. Each test case consists of a single line having
integer N where 1 <= N <= 100000.

Output Specification
For each test case print on a separate line the number of valid sequences modulo 1000000007.

Sample Input
3
2
3
4

Sample Output
55
220
715

The Second Jordanian Collegiate Programming Contest
Princess Sumaya University for Technology (PSUT)
November 17th
, 2012

很好的一道数位DP。

#include <iostream>
#include <stdio.h>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <stack>
#include <math.h>
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
using namespace std ;
typedef long long LL ;
LL dp[][] ;
LL sum[] ;
const LL Mod= ;
int main(){
sum[]= ;
sum[]= ;
for(int i=;i<=;i++){
dp[][i]=-i ;
sum[]+=dp[][i] ;
}
for(int k=;k<=;k++){
LL sum_now= ;
for(int i=;i>=;i--){
dp[k][i]=sum_now+dp[k-][i] ;
if(dp[k][i]>=Mod)
dp[k][i]%=Mod ;
sum_now+=dp[k-][i] ;
if(sum_now>=Mod)
sum_now%=Mod ;
}
sum[k]= ;
for(int i=;i<=;i++){
sum[k]+=dp[k][i] ;
if(sum[k]>=Mod)
sum[k]%=Mod ;
}
}
int N ,T;
cin>>T ;
while(T--){
cin>>N ;
cout<<(sum[N]+Mod)%Mod<<endl ;
}
return ;
}