• 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. (转)使用参数SQL_SLAVE_SKIP_COUNTER处理mysql slave同步错误讨论

    使用参数SQL_SLAVE_SKIP_COUNTER处理mysql slave同步错误讨论 本文链接地址:http://blog.chinaunix.net/uid-31396856-id-57532 ...

  2. sqlserver 数据库 的数据库个数统计 表个数统计 表的数据量统计(转载)

    http://www.cnblogs.com/qinche/archive/2012/08/09/app.html 由于今天要监控数据,急需统计实例中1有多少库2库里有多少表3每个表有多少数据 --将 ...

  3. Redis list(列表)

    Redis列表是简单的字符串列表,列表是有序的,列表中的元素可以重复. 可以添加一个元素到列表的头部(左边)或者尾部(右边) 一个列表最多可以包含 232 - 1 个元素 (40多亿). 1.lpus ...

  4. 第一天课程-html基础

    一.课程内容: 1.安装需要的软件 安装了三个软件:Adobe Dreamweaver,EmEditor,FSCapture.分别是前端开发软件.功能强大的文本编辑器,截图录屏软件 2.了解文件格式. ...

  5. Mind must be master of the body, strong mind can separate the body from its suffering.

    Mind must be master of the body, strong mind can separate the body from its suffering.意志是身体的主人,有顽强的意 ...

  6. 【虚拟机-远程连接】Azure Linux 虚拟机常见导致无法远程的操作

    对Azure虚拟机的一些操作可能会导致无法远程连接,本文罗列了以下导致不能远程连接的场景: 场景1 - 在虚拟机配置IP地址或MAC地址 场景2 - 错误地修改服务的配置文件 场景3 - 误设置防火墙 ...

  7. Python3+Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )

    !/usr/bin/env python -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )'''from selenium im ...

  8. Windows7(x86) xampp php5.5 imagick install

    I hate windows. 1. 下载安装 ImageMagick, 选择合适您电脑的版本,我下载的是: ImageMagick-6.8.9-1-Q16-x86-dll.exe http://ww ...

  9. AE开发关于OnMapReplaced方法的使用原理

    The OnMapReplaced event is triggered whenever the IMapControl2::Map is replaced by another map, such ...

  10. codeforce Gym 100342H Hard Test (思考题)

    题意:构造让Dijkstra单源最短路算法有效松弛次数最多的数据... 题解:构造,题意换种说法就是更新晚的路径要比更新早的路径短.因为所有点都会更新一次,那么按照更新时间形成一条链,即到最后一个点的 ...