博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
FZU 1876 JinYueTuan(排列组合)
阅读量:7048 次
发布时间:2019-06-28

本文共 2820 字,大约阅读时间需要 9 分钟。

Description

Let’s have a look at the picture below

Now, do you know what it’s? Yeah , O(∩_∩)O~ , It is the game called JinYueTuan. chjing plays it very often years ago. I promise you would like it too. Now I want to introduce it to you. Maybe you have already known it clearly. Just be patient.

JinYueTuan is a famous online game which has been in vogue for a long time. Since it is so exciting a game that a large number of players put themselves in it . Only seven keys on the keyboard will be used in games, each key are assigned to one of the seven sound tracks. During the game, a series of notes may fall in each sound track irregularly. When notes fall down in one sound track, player should press the assigned key at once. If so, then got a “Cool”, or get “Miss” otherwise. You should press the key when the note is almost disappeared at the bottom of the window. If you press the key too early, you will miss the note. There will be a song or some kind of music played when you are playing the game. So you will feel you are a pianist. As you pass a low level .the notes will be more and the speed the notes fall will be very high. And the game will be more exciting .There are a lot of cows who play this game very well. If you have a chance to watch them playing, you would say ‘orz’ from your heart. But as a programmer, we would admire people who write this game more. Here comes the problem.

If you are assigned write a game similar to this game. If there are n different sound tracks and m different notes. How many different ways can you arrange the notes to fall.

Input

There are multiple test cases, each case contains a line of three numbers n, m, p. (0 < n, m < 1000000, 0 < p < 10^10).

Output

Output the result mod p.

Sample Input

2 2 1000

Sample Output

6

Hint

We only care about the figure when the notes are piled up. So please ignore the sequence of the notes falling in different sound tracks.
 
 
把n个轨道看成n-1个隔板,然后就是(n-1+m)! / ( n-1) ! ...
当结果等于0的时候要break ; 才能过~这里简直坑
 
 
#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define root 1,n,1#define lson l,mid,rt<<1#define rson mid+1,r,rt<<1|1#define lr rt<<1#define rr rt<<1|1using namespace std;typedef long long LL;const int inf = 1e9+7;const double PI = acos(-1.0);const double eps = 1e-6 ;const int N = 1010;LL n , m , p ;int main(){ #ifdef LOCAL freopen("in.txt","r",stdin); #endif // LOCAL ios::sync_with_stdio(false); while( cin >> n >> m >> p ) { LL res = 1 ; for( int i = n + m - 1 ; i >= n ; --i ) { res *= i ; res %= p ; if( !res ) break ; } cout << res << endl; }}
View Code

 

 

转载于:https://www.cnblogs.com/hlmark/p/4178010.html

你可能感兴趣的文章
BZOJ 2839 集合计数
查看>>
Luogu P4450 双亲数
查看>>
JavaBean与Map的相互转换
查看>>
CRM系统模型
查看>>
Cocos Lua的Touch 点击事件添加
查看>>
zabbix实现mysql数据库的监控(二)
查看>>
Select2 多层次赋值时异步赋值的问题
查看>>
无法创建连接器。 无法连接来自不同容器的可执行文件
查看>>
IDEA项目显示树形结构
查看>>
URL的编码和解码
查看>>
c语言有指针的原因二
查看>>
BZOJ 5302: [Haoi2018]奇怪的背包
查看>>
SpringMVC由浅入深day01_3非注解的处理器映射器和适配器
查看>>
移动开发项目记录分享
查看>>
UI: 标题栏
查看>>
动态代理
查看>>
【hiho】36 二分·二分查找【二分查找】
查看>>
在一周之内,快速看完整部教材,列出你不懂的5-10个问题,发布在个人博客上。...
查看>>
Javascript:作用域 学习总结
查看>>
c# 屏蔽快捷键
查看>>