• 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 NN (1 \le N \le 1000000)(1≤N≤1000000), 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)(1≤Ui​≤1000000), 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

一个人一个人的安排,组合数问题
如 :
C(,)* C(,)=
 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const ll mod=1e9+;
int n;
const int N=1e6+;
ll a[N],sum[N],f[N];
ll mul1(ll a,ll b){
a%=mod;b%=mod;
return a*b%mod;
}
ll mul2(ll a,ll b ,ll c){
a%=mod;b%=mod;c%=mod;
return a*b%mod*c%mod;
}
void egcd(ll a,ll b,ll &x,ll&y){
ll d=a;
if(!b){
x=;y=;
return ;
}
else{
egcd(b,a%b,y,x);
y-=(a/b)*x;
}
// return d;
}
ll inv(ll n){
ll x,y;
egcd(n,mod,x,y);
return (x%mod+mod)%mod;
}
void init()
{
f[]=;
for(int i=;i<=;i++){
f[i]=(f[i-]*i)%mod;
}
}
int main()
{ init();
while(~scanf("%d",&n)){
memset(sum,,sizeof(sum));
for(int i=;i<=n;i++){
scanf("%lld",&a[i]);
sum[i]=sum[i-]+a[i];
}
ll ans=;
for(int i=n;i>;i--){
//ans=(ans*f[sum[i]]%mod*inv(f[a[i]])%mod*inv[f[sum[i-1]]%mod)%mod;
ans=(ans*mul2(f[sum[i]],inv(f[a[i]]),inv(f[sum[i-]])))%mod;
}
printf("%lld\n",ans);
}
return ;
}

Persona5的更多相关文章

  1. icpc 江苏 D Persona5 组合数学 大数阶乘(分段阶乘) 大数阶乘模板

    Persona5 is a famous video game. In the game, you are going to build relationship with your friends. ...

  2. The 2018 ACM-ICPC China JiangSu Provincial Programming Contest快速幂取模及求逆元

    题目来源 The 2018 ACM-ICPC China JiangSu Provincial Programming Contest 35.4% 1000ms 65536K Persona5 Per ...

  3. The 2018 ACM-ICPC China JiangSu Provincial Programming Contest(第六场)

    A Plague Inc Plague Inc. is a famous game, which player develop virus to ruin the world. JSZKC wants ...

  4. mona!mona!mona!

    $ PS: $ 关于\(mona\) 是只很棒的猫啦!想知道的可以自己去看\(persona5\)的游戏流程或者动画版啦. \(PPS:\) 补充一下设定啊,\(mona\)是摩尔加纳(原名)的代号啦 ...

  5. windows下hashcat利用GPU显卡性能破解密码

    由于一般密码破解工具的破解速度实在是太慢,而且支持的密码破解协议也不多,暴力破解的话,有的密码1年时间也破不出来,用字典跑的话必须要明文密码在字典里才行,而且密码字典太大的话,也很浪费时间,跑不出来也 ...

随机推荐

  1. java join 方法的使用

    在很多情况下,主线程创建并启动子线程,如果子线程中要进行大量的耗时运算,主线程往往将早于子线程结束之前结束.这时,如果主线程想等待子线程执行完成之后再结束,比如子线程处理一个数据,主线程要取得这个数据 ...

  2. vfp使用笔记

    1:update数据,根据记录中某个字段的值,从另一个表中查询并填充数据 UPDATE cs2013yy SET cs2013yy.ksh=NVL((SELECT cs2013gkbm.ksh FRO ...

  3. elasticsearch 2.4 windows版jvm内存设置

    本文编写目的是因为网上有很多es修改内存配置的文章,方法也各有不同,但在我的情况下(es 2.4 windows版)发现很多方法都是无效的,有效只有以下方法 第一个是xms,第二个是xmx

  4. kmem_alloc

    http://www.lehman.cuny.edu/cgi-bin/man-cgi?kmem_alloc+9

  5. fiddler设置只抓取某一域名请求

    简单易懂~

  6. MySQL开启skip-name-resolve和skip-networking优化

    使用skip-name-resolve增加远程连接速度 skip-name-resolve 该选项表示禁用DNS解析,属于官方一个系统上的特殊设定不管,链接的的方式是经过hosts或是IP的模式,他都 ...

  7. Python+selenium整合自动发邮件功能

    主要实现的目的是:自动将测试报告以邮件的形式通知相关人员 from HTMLTestRunner import HTMLTestRunner import HTMLTestReport from em ...

  8. vue.js的package.json相关问题解惑

    使用vue-cli创建vue.webpack项目,在项目中用到了iSlider移动端滑动插件,只在本地命令工具中npm install islider.js:提交之后,partner下载代码后一直运行 ...

  9. 【TensorFlow入门完全指南】基本操作

    众所周知我暂时弃掉了那个音乐生成的坑,原因是我的代码写得还不够纯熟…… 现在我找到了一个项目,用来从代码基础开始补起,同时写下学习笔记. 项目地址:https://github.com/aymeric ...

  10. CF Gym 100187M Heaviside Function(二分)

    题意:给你一个函数和一些系数,给你一堆询问,求函数值. 根据s的符号,分成两组讨论,函数值与比x小的系数数量有关,二分输出答案. #include<cstdio> #include< ...