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 <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <algorithm>
#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|1
using namespace std; typedef long long LL;
const int inf = 1e9+;
const double PI = acos(-1.0);
const double eps = 1e- ;
const int N = ;
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 = ;
for( int i = n + m - ; i >= n ; --i ) {
res *= i ; res %= p ;
if( !res ) break ;
}
cout << res << endl;
}
}
 

FZU 1876 JinYueTuan(排列组合)的更多相关文章

  1. FOJ (FZU) 1476 矩形的个数 排列组合。

    http://acm.fzu.edu.cn/problem.php?pid=1476  Problem Description 在一个3*2的矩形中,可以找到6个1*1的矩形,4个2*1的矩形3个1* ...

  2. 学习sql中的排列组合,在园子里搜着看于是。。。

    学习sql中的排列组合,在园子里搜着看,看到篇文章,于是自己(新手)用了最最原始的sql去写出来: --需求----B, C, F, M and S住在一座房子的不同楼层.--B 不住顶层.C 不住底 ...

  3. .NET平台开源项目速览(11)KwCombinatorics排列组合使用案例(1)

    今年上半年,我在KwCombinatorics系列文章中,重点介绍了KwCombinatorics组件的使用情况,其实这个组件我5年前就开始用了,非常方便,麻雀虽小五脏俱全.所以一直非常喜欢,才写了几 ...

  4. 【原创】开源.NET排列组合组件KwCombinatorics使用(三)——笛卡尔积组合

           本博客所有文章分类的总目录:本博客博文总目录-实时更新 本博客其他.NET开源项目文章目录:[目录]本博客其他.NET开源项目文章目录 KwCombinatorics组件文章目录: 1. ...

  5. 【原创】开源.NET排列组合组件KwCombinatorics使用(二)——排列生成

           本博客所有文章分类的总目录:本博客博文总目录-实时更新 本博客其他.NET开源项目文章目录:[目录]本博客其他.NET开源项目文章目录 KwCombinatorics组件文章目录: 1. ...

  6. 【原创】开源.NET排列组合组件KwCombinatorics使用(一)—组合生成

           本博客所有文章分类的总目录:本博客博文总目录-实时更新 本博客其他.NET开源项目文章目录:[目录]本博客其他.NET开源项目文章目录 KwCombinatorics组件文章目录: 1. ...

  7. hdu1521 排列组合(指数型母函数)

    题意: 有n种物品,并且知道每种物品的数量ki.要求从中选出m件物品的排数.         (全题文末) 知识点: 普通母函数 指数型母函数:(用来求解多重集的排列问题) n个元素,其中a1,a2, ...

  8. [leetcode] 题型整理之排列组合

    一般用dfs来做 最简单的一种: 17. Letter Combinations of a Phone Number Given a digit string, return all possible ...

  9. 排列组合算法(PHP)

    用php实现的排列组合算法.使用递归算法,效率低,胜在简单易懂.可对付元素不多的情况. //从$input数组中取$m个数的组合算法 function comb($input, $m) { if($m ...

随机推荐

  1. JS 逻辑非!简单总结

    !""                  true!"aaa"          false""==false          true ...

  2. Cent OS 7 VNC 安装

    关闭防火墙 关闭selinux 挂载光盘到本地 #yum install tigervnc-server -y #cp /lib/systemd/system/vncserver@.service / ...

  3. linux ---apache的安装和配置

    linux环境下的安装:yum安装和tar包安装 yum安装: 首先安装php环境 yum install php55w yum install php55w-mysql yum install ph ...

  4. 外包项目测试工作量评估指南&外包项目测试验收流程

    ## ### 外包项目测试工作量评估指南 1.目的        编写本指导书的目的旨在为我公司进行测试外包服务工作进行指导,帮助项目经理和相关人员编写测试方案.评估工作量.制定测试计划和测试策略等, ...

  5. 设置intellij IDEA编辑框背景色

    首先是打开idea开发工具,然后点击左上角的File,选择Settings设置 应用即时生效,无需重启idea

  6. STM32 通用定时器好文章收藏

    https://blog.csdn.net/fengshuiyue/article/details/79150724 单片机入门学习十三 STM32单片机学习十 通用定时器 里面写的挺不错,图文并茂, ...

  7. C#基础提升系列——C#文件和流

    C#文件和流 本文主要是对C#中的流进行详细讲解,关于C#中的文件操作,考虑到后期.net core跨平台,相关操作可能会发生很大变化,所以此处不对文件系统(包括目录.文件)过多的讲解,只会描述出在. ...

  8. Vue $ref 的用法

    <div id="app"> <cpn $ref="item"></cpn> <cpn></cpn> ...

  9. macOS 和 Linux 的内核区别

    有些人可能会认为 macOS 和 Linux 内核之间存在相似之处,因为它们可以处理类似的命令和类似的软件.有些人甚至认为苹果公司的 macOS 是基于 Linux 的.事实上是,两个内核有着截然不同 ...

  10. php fmod()函数 语法

    php fmod()函数 语法 作用:fmod()函数的作用是两个数值做除法运算后的余数 语法:fmod(X,Y).大理石平台哪家好 参数: 参数 描述 X 必须,X为除数 Y 必须,被除数,如果Y为 ...