Description

Mr. Mindless has many balls and many boxes,he wants to put all the balls into some of the boxes.Now, he wants to know how many different solutions he can have.
you know,he could put all the balls in one box,and there could be no balls in some of the boxes.Now,he tells you the number of balls and the numbers of boxes, can you to tell him the number of different solutions? Because the number is so large, you can just tell him the solutions mod by a given number C.
Both of boxes and balls are all different.

Input

There are multiple testcases. In each test case, there is one line cantains three integers:the number of boxes ,the number of balls,and the given number C separated by a single space.All the numbers in the input are bigger than 0 and less than 2^63.

Output

For each testcase,output an integer,denotes the number you will tell Mr. Mindless

Sample Input

3 2 4
4 3 5

Sample Output

1
4

Hint

简单题,快速幂
/***************************************************/
数据更新了就wa了!!!

#include<stdio.h>
typedef long long ll;
ll quickmod(ll a, ll b, ll m)
{
ll ans = 1;
while (b)
{
if (b & 1)
{
ans = (ans%m*a) % m;
b--;
}
b >>= 1;
a = a%m*a%m;
}
return ans%m;
}
int main()
{
ll m, n, c;
while (~scanf("%lld%lld%lld", &n, &m, &c))
{
printf("%lld\n", quickmod(n, m, c));
}
return 0;
}
/**********************************************************************
Problem: 1162
User: leo6033
Language: C++
Result: WA
**********************************************************************/
改成了unsigned long long以后直接快速幂  wa!!!
然后看了别人的博客之后 用二分法实现乘法  这数据是要有多大!QAQ

#include<stdio.h>
typedef unsigned long long ll;
ll mod_(ll a, ll b, ll m)
{
if (b == 0)
return 0;
ll r = mod_(a, b / 2, m);
r = (r + r) % m;
if (b % 2)
r = (r + a) % m;
return r;
}
ll mod(ll a, ll b, ll c)
{
if (b == 0)return 1;
ll r = mod(a, b / 2, c);
r = mod_(r, r, c);
if (b % 2)
r = mod_(r, a, c);
return r;
}
int main()
{
ll m, n, c;
while (~scanf("%lld%lld%lld", &n, &m, &c))
{
printf("%lld\n", mod(n, m, c));
}
return 0;
} /**********************************************************************
Problem: 1162
User: leo6033
Language: C++
Result: AC
Time:28 ms
Memory:1120 kb
**********************************************************************/


最新文章

  1. maven 项目出现 java.lang.ClassNotFoundException
  2. 8.4.2 Fresco
  3. Linux 网络编程(TCP)
  4. 302 Moved Temporarily
  5. C#枚举类型和结构体
  6. tomcat bug之部署应用的时候经常会发上startup failed due to previous errors
  7. iOS学习笔记-CoreData
  8. SetWindowLong
  9. poj2524
  10. SpringMVC拦截器 - 设置不拦截html,js等静态文件
  11. docker学习笔记(二)
  12. Linux中Mysql root用户看不到mysql库问题解决方式
  13. 水晶报表中&quot;已达到系统管理员配置的最大报表处理作业数限制&quot;错误的处理
  14. Linux常用命令(第二版) --压缩解压缩命令
  15. 【刷题】【LeetCode】007-整数反转-easy
  16. FPC导通阻抗计算
  17. @Schedule注解中的Cron表达式读取properties的方法
  18. 汕头市队赛 SRM 07 D 天才麻将少女kpm
  19. linux --- 2.常用命令 , python3, django安装
  20. 【转】 Ubuntu在启动器添加程序快捷方式

热门文章

  1. 《设计模式》-原则五:合成/聚合复用原则(CARP)
  2. Spring MVC表单防重复提交
  3. PIE的使用
  4. 用CSS3写圆角(超简单)
  5. Linux常用的20个命令
  6. 用phpUnit入门TDD
  7. POJ 3164 Command Network ( 最小树形图 朱刘算法)
  8. js中call与apply的区别以及使用~
  9. J - Clairewd’s message HDU - 4300(扩展kmp)
  10. Go语言的接口interface、struct和组合、继承