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年时间也破不出来,用字典跑的话必须要明文密码在字典里才行,而且密码字典太大的话,也很浪费时间,跑不出来也 ...
随机推荐
- POJ 3735 Training little cats 矩阵快速幂
http://poj.org/problem?id=3735 给定一串操作,要这个操作连续执行m次后,最后剩下的值. 记矩阵T为一次操作后的值,那么T^m就是执行m次的值了.(其实这个还不太理解,但是 ...
- DevExpress PivotGrid 使用记录
1.自定total值: 调试的时候,如果要定位,给一个index,然后,把e.CustomVale=index++;定位后,监视ds的值,每个ds的值不一样!
- JAVA基础之基本类型包装类、System类、Math类、Arrays类及大数据运算
个人理解: 为了方便运算及调用一些方法,我们需要将基本类型的数值转换为对象:不过转换的时候需要特别注意好它们的类型到底是什么,需要调用方法的类名是哪个!特别注意是Byte常量池的相关问题(==):gc ...
- All boundaries are conventions, waiting to be transcended.
All boundaries are conventions, waiting to be transcended.所有界限都是陈规,等着被打破.
- Android给图片加文字和图片水印
我们在做项目的时候有时候需要给图片添加水印,水寒今天就遇到了这样的问题,所以搞了一个工具类,贴出来大家直接调用就行. /** * 图片工具类 * @author 水寒 * 欢迎访问水寒的个人博客:ht ...
- android 内存泄露测试
Android 程序由java语言编写,android的内存管理与java相似,通过new为对象分配内存,所有对象在java堆内分配空间,对象回收有个垃圾回收器来完成.GC就是垃圾收集的意思(Gaba ...
- python基础教程总结15——1.即时标记
1. 测试文档: # test_input.txt Welcome to World Wide Spam. Inc. These are the corporate web pages of *Wor ...
- IT的学习部落(持续更新)
1.易百教程 - 专注于IT教程和实例 http://www.yiibai.com/ 2.站长特效 - js特效 http://www.zzjs.net/ 3.酷站-享受编程和技术所 ...
- Linux OpenGL 实践篇-16 文本绘制
文本绘制 本文主要射击Freetype的入门理解和在OpenGL中实现文字的渲染. freetype freetype的官网,本文大部分内容参考https://www.freetype.org/fre ...
- Codeforces Round #321 (Div. 2) B. Kefa and Company (尺取)
排序以后枚举尾部.尺取,头部单调,维护一下就好. 排序O(nlogn),枚举O(n) #include<bits/stdc++.h> using namespace std; typede ...