• 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. replcation set (复制集)配置过程 --mongodb

    一,配置规划 复制集原理(基本构成是1主2从的结构,自带互相监控投票机制(Raft(MongoDB)  Paxos(mysql MGR 用的是变种))如果发生主库宕机,复制集内部会进行投票选举,选择一 ...

  2. SpringMVC对HTTP报文体的处理

     客户端和服务端HTTP报文传递消息,而HTTP报文包含报文头和报文体.通常,解析请求参数以及返回页面都不需要我们关心HTTP报文体的读取和生成过程.但在某些特定场景下需要直接到请求报文中读取报文体, ...

  3. PHP开发环境及搭建

    自学PHP中,很多东西都不熟悉,在此做个记录,方便以后再次搭建PHP环境.这篇文章基本按照原文  ThinkPHP5开发环境安装和配置 ,在此感谢该作者 一.实验目的 1.掌握ThinkPHP5(简称 ...

  4. 洛谷P1081 开车旅行70分

    https://www.luogu.org/problem/show?pid=1081 太遗憾了明明写出来了,却把最小值初始值弄小了,从第二个点开始就不可能对了.70分! #include<io ...

  5. where whereis locate find 的用法

    1.where :where ifconfig.用来搜索命令,显示命令是否存在以及路径在哪 2.whereis:whereis vim .用来搜索程序名,而且只搜索二进制文件(参数-b).man说明文 ...

  6. ubuntu和window之间如何共享文件

    参考网上的自己动手实现共享文件: 1.打开虚拟机进入ubuntu系统,先安装增强功能包 2.安装完重启虚拟机后,在window下创建一个专门用来共享的文件夹 3.切换到ubuntu系统,在设备的共享文 ...

  7. Android tess_two Android图片文字识别

    文字识别一般都用的tesseract-ocr. GitHub:https://github.com/tesseract-ocr/tesseract 而Android对应的比较推荐的有个tess-two ...

  8. jsp另外五大内置对象之response-操作重定向

    <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding= ...

  9. ZOJ 3471 Most Powerful (状压DP,经典)

    题意: 有n个原子,每当两个原子碰撞时就会产生能量,并且消耗其中一个原子.已知每两个原子碰撞时消耗其中指定一个原子所产生的能量,问最多能产生多少能量? 思路: 一开始以为是找一个有序序列,使得能量最大 ...

  10. JDBC + SAP云平台 = 运行在云端的数据库应用

    在前一篇文章JPA + EclipseLink + SAP云平台 = 运行在云端的数据库应用我介绍了如何通过JPA和EclipseLink操作部署在SAP云平台上的HANA数据库实例. 在这篇文章里, ...