zoukankan      html  css  js  c++  java
  • Persona5

    •  65536K
     

    Persona5 is a famous video game.

    In the game, you are going to build relationship with your friends.

    You have NN friends and each friends have his upper bound of relationship with you. Let's consider the i^{th}ith friend has the upper bound U_iUi. At the beginning, the relationship with others are zero. In the game, each day you can select one person and increase the relationship with him by one. Notice that you can't select the person whose relationship with you has already reach its upper bound. If your relationship with others all reach the upper bound, the game ends.

    It's obvious that the game will end at a fixed day regardless your everyday choices. Please calculate how many kinds of ways to end the game. Two ways are said to be different if and only if there exists one day you select the different friend in the two ways.

    As the answer may be very large, you should output the answer mod 10000000071000000007

    Input Format

    The input file contains several test cases, each of them as described below.

    • The first line of the input contains one integers N(1 le N le 1000000)(1N1000000), giving the number of friends you have.
    • The second line contains NN integers. The i^{th}ith integer represents U_iUi ( 1 le U_i le 1000000)(1Ui1000000), which means the upper bound with i^{th}ith friend. It's guarantee that the sum of U_iUi is no more than 10000001000000.

    There are no more than 1010 test cases.

    Output Format

    One line per case, an integer indicates the answer mod 10000000071000000007.

    样例输入

    3
    1 1 1
    3
    1 2 3

    样例输出

    6
    60

    题目来源

    The 2018 ACM-ICPC China JiangSu Provincial Programming Contest

    一个人一个人的安排,组合数问题
    如 : 1 2 3
    C(63)* C(32)=60
     1 #include <iostream>
     2 #include <algorithm>
     3 #include <cstring>
     4 #include <cstdio>
     5 #include <vector>
     6 #include <queue>
     7 #include <stack>
     8 #include <cstdlib>
     9 #include <iomanip>
    10 #include <cmath>
    11 #include <cassert>
    12 #include <ctime>
    13 #include <map>
    14 #include <set>
    15 using namespace std;
    16 typedef long long ll;
    17 const ll mod=1e9+7;
    18 int n;
    19 const int N=1e6+9;
    20 ll  a[N],sum[N],f[N];
    21 ll mul1(ll a,ll b){
    22     a%=mod;b%=mod;
    23     return a*b%mod;
    24 }
    25 ll mul2(ll a,ll b ,ll c){
    26     a%=mod;b%=mod;c%=mod;
    27     return a*b%mod*c%mod;
    28 }
    29 void  egcd(ll a,ll b,ll &x,ll&y){
    30     ll d=a;
    31     if(!b){
    32         x=1;y=0;
    33         return ;
    34     }
    35     else{
    36         egcd(b,a%b,y,x);
    37         y-=(a/b)*x;
    38     }
    39 //    return d;
    40 }
    41 ll inv(ll n){
    42     ll x,y;
    43     egcd(n,mod,x,y);
    44     return (x%mod+mod)%mod;
    45 }
    46 void init()
    47 {
    48     f[0]=1;
    49     for(int i=1;i<=1000000;i++){
    50         f[i]=(f[i-1]*i)%mod;
    51     }
    52 }
    53 int main()
    54 {   init();
    55     while(~scanf("%d",&n)){
    56         memset(sum,0,sizeof(sum));
    57     for(int i=1;i<=n;i++){
    58         scanf("%lld",&a[i]);
    59         sum[i]=sum[i-1]+a[i];
    60     }
    61     ll ans=1;
    62 for(int i=n;i>1;i--){
    63     //ans=(ans*f[sum[i]]%mod*inv(f[a[i]])%mod*inv[f[sum[i-1]]%mod)%mod;
    64     ans=(ans*mul2(f[sum[i]],inv(f[a[i]]),inv(f[sum[i-1]])))%mod;
    65 }
    66 printf("%lld
    ",ans);
    67     }
    68     return 0;
    69     }
  • 相关阅读:
    xcode创建多个target,老外的写的懒得翻译了,看图
    错误 解决“Unknown class in Interface Builder file”
    Objectc 动态调用函数
    IPA PNG图片转换
    ObjectiveC的消息传递机制[转]
    [转]获取iOS设备的内存状况
    [转]史上最简单得多选uitableview
    Unity3d 添加IOS View(2)
    Core Animation学习笔记五:CAPropertyAnimation
    MKMapView指定坐标添加大头针
  • 原文地址:https://www.cnblogs.com/tingtin/p/9363398.html
Copyright © 2011-2022 走看看