• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

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 }
View Code 2013-10-07 22:12:19 

 

posted @ 2013-10-07 21:55  HaibaraAi  阅读(130)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3