Timus OJ 1696(URAL) Salary for Robots

1696. Salary for Robots

Time limit: 2.0 second
Memory limit: 64 MB
There are  n robots on planet PTZZZ. Each robot has its own unique rank—an integer from 1 to  n, and should execute all orders from robots with a higher rank.
Once a month all robots get their salary: a positive integer number of credits, not exceeding  k. The salary is paid by an accountant-robot. Salary is so important for robots that the first month when all the robots got their salary was named the First month of the First year. There are  p months in the year on PTZZZ, so the robots get their salary  p times a year.
The salary paid to each robot can be different in different months. If it turns out that all the robots get exactly the same salary as in any month earlier, the accountant-robot will rust of sadness. What is more, the law doesn't allow the accountant-robot to pay salary in such a way that there will be a triple of robots ( abc) with rank of  a higher than rank of  b, rank of  b higher than rank of  c and the salary of  a less than the salary of  b and the salary of  b less than the salary of  c.
The accountant-robot doesn't want to rust, so since the First month of the First year he tries to pay salary in different ways. However, the accountant-robot will rust sooner or later. Your task is to calculate the month number when this will happen.

Input

The only input line contains three space-separated integers  nk and  p—the number of robots on PTZZZ, the maximal possible salary and the number of months in a year, respectively  (1 ≤  n ≤ 1000; 1 ≤  k ≤ 200; 2 ≤  p ≤ 10 9) .

Output

Output the month number the accountant-robot will rust in. Months are numerated 1 to  p.

Sample

input output
3 3 20
7
Problem Author: Igor Chevdar
Problem Source: Ural SU Contest. Petrozavodsk Winter Session, February 2009 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值