Balls in the Boxes
Description
Input
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
#include<cstdio>
#include<iostream>
using namespace std;
typedef unsigned long long ull;
unsigned long long fast_mod(ull a,ull b,ull mod)
{
ull res=0;
while(b)
{
if(b&1) res=(res+a)%mod;
a=(2*a)%mod;
b>>=1;
}
return res;
}
unsigned long long work(ull a,ull b,ull mod)
{
ull res=1;
while(b)
{
if(b&1)
res=fast_mod(res,a,mod);
a=fast_mod(a,a,mod);
b>>=1;
}
return res;
}
int main()
{
ios::sync_with_stdio(false);
ull a,b,c;
while(cin>>a>>b>>c)
{
cout<<work(a,b,c)<<endl;
}
return 0;
}
/**********************************************************************
Problem: 1162
User: song_hai_lei
Language: C++
Result: AC
Time:60 ms
Memory:2180 kb
**********************************************************************/
Balls in the Boxes的更多相关文章
- CSUOJ 1162 Balls in the Boxes 快速幂
Description Mr. Mindless has many balls and many boxes,he wants to put all the balls into some of th ...
- HDU 5810 Balls and Boxes(盒子与球)
Balls and Boxes(盒子与球) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/O ...
- Codeforces Round #158 (Div. 2) C. Balls and Boxes 模拟
C. Balls and Boxes time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- HDU 5810 Balls and Boxes (找规律)
Balls and Boxes 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5810 Description Mr. Chopsticks is i ...
- HDU5810 Balls and Boxes
Balls and Boxes Time Limi ...
- 2016 多校联赛7 Balls and Boxes(概率期望)
Mr. Chopsticks is interested in random phenomena, and he conducts an experiment to study randomness. ...
- HDU 5810 Balls and Boxes 数学
Balls and Boxes 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5810 Description Mr. Chopsticks is i ...
- hdu-5810 Balls and Boxes(概率期望)
题目链接: Balls and Boxes Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/O ...
- Educational Codeforces Round 31- D. Boxes And Balls
D. Boxes And Balls time limit per test2 seconds memory limit per test256 megabytes 题目链接:http://codef ...
随机推荐
- [软件使用][matlab]最近经常用到的一些函数的意思,和用法
① cat(dim,A,B)按指定的维度,将A和B串联,dim是维度,比如1,2.1指列,2指行: ②numel(A),返回数组中,元素的个数 ③gpuArray(A),在gpu中产生一个数组A,一般 ...
- Verilog模块概念和实例化#转载自Jason from Lofter
Verilog模块概念和实例化 模块的概念 模块(module)是verilog最基本的概念,是v设计中的基本单元,每个v设计的系统中都由若干module组成. 1.模块在语言形式上是以关键词modu ...
- hdu 1233 (prim,最小生成树) 还是畅通工程
还是畅通工程Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- pat 1058 A+B in Hogwarts(20 分)
1058 A+B in Hogwarts(20 分) If you are a fan of Harry Potter, you would know the world of magic has i ...
- scipy.sparse的csc_matrix、csr_matrix与coo_matrix区别与应用(思维导图)
- Laravel 菜鸟的晋级之路
第一阶段:简单的增删改查 这是最开始接触Laravel的一个阶段.如果有PHP经验,那么应该能很快找到MVC的路径,然后驾轻就熟的开始写起来.虽然还显得有些笨拙,不过很快就能做出一些内容了.如果没有P ...
- 【集合系列】- 深入浅出的分析 Hashtable
一.摘要 在集合系列的第一章,咱们了解到,Map 的实现类有 HashMap.LinkedHashMap.TreeMap.IdentityHashMap.WeakHashMap.Hashtable.P ...
- 面向对象之classmethod和staticmethod(python内置装饰器)
对象的绑定方法复习classmethodstaticmethod TOC 对象的绑定方法复习 由对象来调用 会将对象当做第一个参数传入 若对象的绑定方法中还有其他参数,会一并传入 classmetho ...
- 面试官:CPU百分百!给你一分钟,怎么排查?有几种方法?
Part0 遇到了故障怎么办? 在生产上,我们会遇到各种各样的故障,遇到了故障怎么办? 不要慌,只有冷静才是解决故障的利器. 下面以一个例子为例,在生产中碰到了CPU 100%的问题怎么办? 在生产中 ...
- Tomcat安装和使用
1.Tomcat简介 Tomcat是Apache开源组织下的开源免费的中小型Web应用服务器,支持javaEE中的servlet和jsp规范. 2.Windows版安装和使用 下载地址:http:// ...