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 ...
随机推荐
- Java基础 ArrayList源码分析 JDK1.8
一.概述 本篇文章记录通过阅读JDK1.8 ArrayList源码,结合自身理解分析其实现原理. ArrayList容器类的使用频率十分频繁,它具有以下特性: 其本质是一个数组,因此它是有序集合 通过 ...
- C#:转义字符 \n 和 \r 的区别
1.\n,换行符,作用是换行符之后的字符换到下一行: 例如:1234/n567 得出的结果是1234 567 2.而\r,回车符,作用是回车符之后的字符会回到当前行的最前面,把回车符之前的字符覆 ...
- 一文看懂 K8s 日志系统设计和实践
上一篇中我们介绍了为什么需要一个日志系统.为什么云原生下的日志系统如此重要以及云原生下日志系统的建设难点,相信DevOps.SRE.运维等同学看了是深有体会的.本篇文章单刀直入,会直接跟大家分享一下如 ...
- nyoj 70-阶乘因式分解(二)(数学)
70-阶乘因式分解(二) 内存限制:64MB 时间限制:3000ms 特判: No 通过数:7 提交数:7 难度:3 题目描述: 给定两个数n,m,其中m是一个素数. 将n(0<=n<=2 ...
- django_4数据库2——表外键
表关系: many to one many to many one to one many to one 记录是如何创建出来的? 先创建one,在在创建many,创建时加入ForeignKe ...
- SecureCRT 多个会话显示在同一窗口
- workspaces only allow trusted client with self-signed cert
1. 生成ca. openssl genrsa -out CA_neonone.workspace.key 2048 openssl req -x509 -new -nodes -key CA_neo ...
- PHP中16个高危函数
php中内置了许许多多的函数,在它们的帮助下可以使我们更加快速的进行开发和维护,但是这个函数中依然有许多的函数伴有高风险的,比如说一下的16个函数不到万不得已不尽量不要使用,因为许多“高手”可以通过这 ...
- 添加ssh服务构建新镜像-docker commit 方式01
添加ssh服务构建新镜像-docker commit 方式 1:docker commit构建自定义镜像---一般不推荐使用这种方式构建新镜像 1:ubuntu基础镜像下载 ubuntu@ubuntu ...
- Redis集群同步问题
之前被面试官问到:Redis集群中主从数据同步是从库异步读取主库,那么Redis集群其他主与主之间的数据是怎么共享的呢?或者说是怎么同步的? emmmm……当时我就懵逼了,这不是考试范围啊卧槽~只能老 ...