• HDU 2643 Rank


    Problem Description
    Recently in Teddy's hometown there is a competition named "Cow Year Blow Cow".N competitors had took part in this competition.The competition was so intense that the rank was changing and changing.
    Now the question is:
    How many different ways that n competitors can rank in a competition, allowing for the possibility of ties. 
    as the answer will be very large,you can just output the answer MOD 20090126.
    Here are the ways when N = 2:
    P1 < P2
    P2 < P1
    P1 = P2 
     
    Input
    The first line will contain a T,then T cases followed.
    each case only contain one integer N (N <= 100),indicating the number of people.
     
    Output
    One integer pey line represent the answer MOD 20090126.

    第二类斯特林数,把排名看做箱子,相当于n个不同的球放一个箱子,放两个箱子。。放n个不同的箱子的方法总和

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <queue>
    #include <bitset>
    using namespace std;
    typedef long long LL;
    #define MOD 20090126
    LL s[105][105],n,k,T,fac[105];
    int main(){
      // freopen("test.in","r",stdin);
      cin >> T;
      memset(s,0,sizeof(s));
      s[1][1] = 1;
      fac[1] = 1;
      for (int i=2;i<=100;i++){
        fac[i] = fac[i-1] * i % MOD;
        s[i][1] = 1;
        s[i][0] = 0;
        for (int j=2;j<=100;j++){
          if (i >= j)
            s[i][j] = (s[i-1][j-1] % MOD + j*s[i-1][j] % MOD) % MOD;
          else
            s[i][j] = 0;
        }
      }
      // cout <<s[3][1] << s[3][2] << s[3][3]<< endl;
      for (int i=1;i<=T;i++){
        cin >> n;
        LL ans = 0;
        for (int i=1;i<=n;i++){
          ans = (ans + s[n][i] * fac[i]) % MOD;
        }
        cout << ans << endl;
      }
      return 0;
    }
    View Code
  • 相关阅读:
    Mysql高级第一天(laojia)
    Mysql初级第三天(wangyun)
    Mysql初级第二天(wangyun)
    Mysql初级第一天(wangyun)
    Spring的源码解析
    JAVA8新特性
    java8
    JMM内存模型
    JAVA并发工具类
    mybatis
  • 原文地址:https://www.cnblogs.com/ToTOrz/p/7390134.html
Copyright © 2020-2023  润新知