标签:represent ems uil ext assert code person else reg
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
The input file contains several test cases, each of them as described below.
There are no more than 1010 test cases.
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 #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\n",ans); 67 } 68 return 0; 69 }
标签:represent ems uil ext assert code person else reg
原文地址:https://www.cnblogs.com/tingtin/p/9363398.html