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 ...
随机推荐
- [springboot 开发单体web shop] 7. 多种形式提供商品列表
上文回顾 上节 我们实现了仿jd的轮播广告以及商品分类的功能,并且讲解了不同的注入方式,本节我们将继续实现我们的电商主业务,商品信息的展示. 需求分析 首先,在我们开始本节编码之前,我们先来分析一下都 ...
- vim查询替换
查询: 在民令模式输入/或者? n/N 替换:
- 关于log4j
搭建完maven+SpringMVC以后,我们还需要添加日志功能,方便记录应用在应用中产生的日志信息. 1.添加依赖包:依赖中除了对slf4j依赖外还有对邮件插件的依赖.当遇到报错的时候可以发送邮件到 ...
- java.lang.NoSuchMethodError: org.apache.tomcat.JarScanner.scan(Ljavax/servlet/ServletContext;Ljava/lang/ClassLoader;Lorg/apache/tomcat/JarScannerCallback;Ljava/util/Set;)V
java.lang.NoSuchMethodError: org.apache.tomcat.JarScanner.scan(Ljavax/servlet/ServletContext;Ljava/l ...
- selenium中延时等待三种方式
selenium中的延时等待方式有三种:强制等待:sleep() 隐示等待:implicitly_wait() 显示等待 WebDriverWait() 1.强制等待:sleep(),time模块 ...
- salesforce lightning零基础学习(十五) 公用组件之 获取表字段的Picklist(多语言)
此篇参考:salesforce 零基础学习(六十二)获取sObject中类型为Picklist的field values(含record type) 我们在lightning中在前台会经常碰到获取pi ...
- MySQL锁会不会,你就差看一看
数据库锁知识 不少人在开发的时候,应该很少会注意到这些锁的问题,也很少会给程序加锁(除了库存这些对数量准确性要求极高的情况下),即使我们不会这些锁知识,我们的程序在一般情况下还是可以跑得好好的.因为这 ...
- Docker-Compose基础与实战,看这一篇就够了
what & why Compose 项目是 Docker 官方的开源项目,负责实现对 Docker 容器集群的快速编排.使用前面介绍的Dockerfile我们很容易定义一个单独的应用容器.然 ...
- c#关于数据和方法在不同类中的引用-xdd
关于数据和方法在不同类中的引用 using System; using System.Collections.Generic; using System.Linq; using System.Text ...
- 2019年12月1日Linux开发手记
配置ubuntu摄像头: 1.设置→添加→usb控制器→兼容usb3.0 2.虚拟机→可移动设备→web camera→连接(断开主机) 3.查看是否配置成功,打开终端,输入: susb ls /de ...