FZU 1759-Super A^B mod C
传送门:http://acm.fzu.edu.cn/problem.php?pid=1759
Accept: 1161 Submit: 3892
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
Given A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,C<=1000000000,1<=B<=10^1000000).
Input
Output
Sample Input
Sample Output
24
#include<stdio.h>
#include<string.h>
typedef long long LL; const int MAXX = 1e6;
LL c,d;
char b[MAXX+]; LL quick_pow(LL a, LL b, LL mod) {
LL ans = ;
while(b > ) {
if(b&) {
b--;
ans = ans *a %mod;
}
b>>=;
a=a*a%mod;
}
return ans;
} LL Euler (LL n) {
LL rea=n;
for(int i=; i*i<=n; i++)
if(n%i==)
{
rea=rea-rea/i;
do
n/=i;
while(n%i==);
}
if(n>)
rea=rea-rea/n;
return rea;
}
LL jieguo(LL a,char b[],LL c,LL mod) {
LL sum = ;
sum = (b[] - '') % mod;
LL len = strlen(b);
for(int i = ;i<len;i++) {
sum*=;
sum=(sum+b[i]-'')%mod;
}
return quick_pow(a,sum+mod,c);
}
int main() { while(scanf("%lld%s%lld", &c, b, &d)!=EOF){
LL ola=Euler(d);
printf("%lld\n",jieguo(c,b,d,ola));
}
return ;
}
FZU 1759-Super A^B mod C的更多相关文章
- FZU 1759 Super A^B mod C 指数循环节
Problem 1759 Super A^B mod C Time Limit: 1000 mSec Memory Limit : 32768 KB Problem Description G ...
- FOJ ——Problem 1759 Super A^B mod C
Problem 1759 Super A^B mod C Accept: 1368 Submit: 4639Time Limit: 1000 mSec Memory Limit : 32 ...
- fzou 1759 Super A^B mod C
Problem 1759 Super A^B mod CAccept: 456 Submit: 1488Time Limit: 1000 mSec Memory Limit : 32768 ...
- FZU:1759-Problem 1759 Super A^B mod C (欧拉降幂)
题目链接:http://acm.fzu.edu.cn/problem.php?pid=1759 欧拉降幂是用来干啥的?例如一个问题AB mod c,当B特别大的时候int或者longlong装不下的时 ...
- FZU Super A^B mod C(欧拉函数降幂)
Problem 1759 Super A^B mod C Accept: 878 Submit: 2870 Time Limit: 1000 mSec Memory Limit : 327 ...
- FZU 1759 题解 欧拉降幂
本题考点:欧拉降幂 Super A^B mod C Given A,B,C, You should quickly calculate the result of A^B mod C. (1<= ...
- Day7 - B - Super A^B mod C FZU - 1759
Given A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,C<=1000000000,1<=B ...
- Super A^B mod C (快速幂+欧拉函数+欧拉定理)
题目链接:http://acm.fzu.edu.cn/problem.php?pid=1759 题目:Problem Description Given A,B,C, You should quick ...
- FZU 1759 欧拉函数 降幂公式
Description Given A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,C<=1000 ...
- FZU 2212 Super Mobile Charger(超级充电宝)
[Description] [题目描述] While HIT ACM Group finished their contest in Shanghai and is heading back Harb ...
随机推荐
- IQueryable 与 IEnumberable 接口的区别
IQueryable 与 IEnumberable 接口的区别是: IEnumberable<T> 泛型类在调用自己的 SKip 和 Take 等扩展方法之前数据就已经加载在本地内存里了, ...
- chrome手机模拟器显示尺寸不正确
存在问题: chrome网页调试器中小屏幕时显示尺寸不正确 原因: 自动调整了dpi,导致不是设计的结果 解决方法: 在<head>中添加如下语句: <meta name=" ...
- JSON 对象 与 字符串 互转
$sui = [ 'xixixi' => 'suisuisui', 'hahaha' => 'longlonglong', ]; $data = json_encode($sui); pr ...
- 【转】Vue-详解设置路由导航的两种方法: <router-link :to="..."> 和router.push(...)
一.<router-link :to="..."> to里的值可以是一个字符串路径,或者一个描述地址的对象.例如: // 字符串 <router-link to= ...
- Mysql锁(翻译)
内容主要是对mysql文档的翻译. 1. shared(s) 共享锁2. exclusive(x) 排它锁 innodb的s锁和x锁是行级锁.事务T1获得s锁,事务T2仍然可以获得s锁.事务T1获得x ...
- python 豆瓣验证码识别总结
总结: pytesseract 识别比较标准的图片 识别成功率 还是不错的. 验证码的图片识别 需要先处理好 再用pytesseract 识别 from PIL import Image ...
- Author and Submission Instructions
This document contains information about the process of submitting a paper to NIPS 2014. You can als ...
- python之路-网络基础
1.什么是网络: 通过网络设备将各个设备连接在一起,使用协议让设备之间可以通信,共享资源,这些组成了一个网络. 2.osi七层模式: 国际标准化组织(ISO)创建OSI(开放系统互联)参考模型,希望不 ...
- 跑caffe过程中的备忘
1*1卷积比如一张500*500且厚度depth为100的图片在20个filter上做1*1卷积,那么结果大小为500*500*20 只有池化改变图片的大小 一个大的全连接层可以理解为一个神经网络,这 ...
- html随笔CSS(*^__^*)
控制文本显示字数,超过规定的文本长度 x显示... white-space:nowrap; //规定不能换行 overflow:hidden; text-overflow:ellips ...