Warm up 3 [H] Skill
你为何这么叼!
[H] 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
1 #include <cstdio> 2 #include <vector> 3 #include <cstring> 4 #include <queue> 5 #include <algorithm> 6 using namespace std; 7 #define maxn 100005 8 #define mod 1000000007 9 #define ll long long 10 int n,m; 11 ll a[maxn]; 12 int ex_gcd(int a,int b,int &x,int &y){ 13 int res; 14 if(!b){x=1;y=0;return a;} 15 res=ex_gcd(b,a%b,y,x); 16 y-=x*(a/b); 17 return res; 18 } 19 int main(){ 20 int t; 21 a[1]=10; 22 for(int i=2;i<maxn;i++){ 23 a[i]=a[i-1]*(9+i)%mod; 24 int x,y; 25 ex_gcd(i,mod,x,y); 26 a[i]=a[i]*((x+mod)%mod)%mod; 27 } 28 scanf("%d",&t); 29 while(t--){ 30 scanf("%d",&n); 31 printf("%I64d\n",a[n]); 32 } 33 return 0; 34 }
浙公网安备 33010602011771号