zoukankan      html  css  js  c++  java
  • 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[100008][10] ;
    LL sum[100008] ;
    const LL Mod=1000000007 ;
    int main(){
       sum[1]=10 ;
       sum[2]=0 ;
       for(int i=0;i<=9;i++){
            dp[2][i]=10-i ;
            sum[2]+=dp[2][i] ;
       }
       for(int k=3;k<=100000;k++){
           LL sum_now=0 ;
           for(int i=9;i>=0;i--){
               dp[k][i]=sum_now+dp[k-1][i] ;
               if(dp[k][i]>=Mod)
                  dp[k][i]%=Mod ;
               sum_now+=dp[k-1][i] ;
               if(sum_now>=Mod)
                  sum_now%=Mod ;
           }
           sum[k]=0 ;
           for(int i=0;i<=9;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 0 ;
    }
  • 相关阅读:
    复利计算器2.01
    复利计算器2.0
    0429团队3.0
    0428 团队项目合作2.0作业
    "数学口袋精灵"bug
    操作系统-实验2
    博客评论
    复利计算升级
    0408 结对合作
    0406复利计算5.0
  • 原文地址:https://www.cnblogs.com/liyangtianmen/p/3355379.html
Copyright © 2011-2022 走看看