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 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的更多相关文章
- icpc 江苏 D Persona5 组合数学 大数阶乘(分段阶乘) 大数阶乘模板
Persona5 is a famous video game. In the game, you are going to build relationship with your friends. ...
- The 2018 ACM-ICPC China JiangSu Provincial Programming Contest快速幂取模及求逆元
题目来源 The 2018 ACM-ICPC China JiangSu Provincial Programming Contest 35.4% 1000ms 65536K Persona5 Per ...
- 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 ...
- mona!mona!mona!
$ PS: $ 关于\(mona\) 是只很棒的猫啦!想知道的可以自己去看\(persona5\)的游戏流程或者动画版啦. \(PPS:\) 补充一下设定啊,\(mona\)是摩尔加纳(原名)的代号啦 ...
- windows下hashcat利用GPU显卡性能破解密码
由于一般密码破解工具的破解速度实在是太慢,而且支持的密码破解协议也不多,暴力破解的话,有的密码1年时间也破不出来,用字典跑的话必须要明文密码在字典里才行,而且密码字典太大的话,也很浪费时间,跑不出来也 ...
随机推荐
- nodejs 实践:express 最佳实践(二) 中间件
express 最佳实践(二):中间件 第一篇 express 最佳实践(一):项目结构 express 中最重要的就是中间件了,可以说中间件组成了express,中间件就是 express 的核心. ...
- vue-cli3项目中解决动态引入图片img404的问题
博主最近手头再做一个项目,需要调用天气接口,并且还要动态显示天气相关图片icon. 本来以为没什么大问题,结果硬生生被这个动态图片路径搞得民不聊生(博主还是 too young,too simple~ ...
- iOS-Swift相比Objective-C有哪些优缺点
Swift,是苹果于2014年WWDC(苹果开发者大会)发布的新开发语言,可与Objective-C共同运行于Mac OS和iOS平台,用于搭建基于苹果平台的应用程序.它是一款易学易用的编程语言,而且 ...
- JFinal视频教程
最近开始录制JFinal视频教程,发布在腾讯课堂上,免费公开面向JFinal开发者,作为JFinal开发者入门学习.实际项目用遇到问题寻找解决方案的最好途径. 目前JFinal课程已经开始更新. 腾讯 ...
- 使用jmeter测试数据库性能
出现如图所示的问题 解决办法: 1.下载驱动包,将mysql-connector-Java.jar分别放到Jmeter和Java安装目录的lib和ext目录下 链接:http://pan.baidu. ...
- js进阶之闭包
1.首先说下什么是闭包,闭:封闭,包:就像我们的包包~:虽然我在扯淡但是也有其道理咯,闭包就有点像java里面的封装一样,包属性和方法都封装到对象内部,在外部通过共有的get.set方法获取或者设置其 ...
- COGS 1715. [CQOI2011]动态逆序对
★★★ 输入文件:inverse.in 输出文件:inverse.out 简单对比时间限制:2 s 内存限制:128 MB [题目描述] 对于序列A,它的逆序对数定义为满足i<j ...
- 安装指定版本的minikube
Minikube是什么? Kubernetes集群的安装和部署对于很多初学者来说是一道坎.为了方便大家开发和体验Kubernetes,Kubernetes开源社区提供了可以在本地部署的Minikube ...
- Java的数组与内存控制
1 数组基础 数组描述的是相同类型的若干个数据,按照一定的先后次序排列组合而成.其中,每一个数据称作一个数组元素(item),每个数组元素可以通过一个下标/索引来(index)访问它们. 数组 ...
- [CV笔记]图像特征提取三大法宝:HOG特征,LBP特征,Haar特征
(一)HOG特征 1.HOG特征: 方向梯度直方图(Histogram of Oriented Gradient, HOG)特征是一种在计算机视觉和图像处理中用来进行物体检测的特征描述子.它通过计算和 ...