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 ...
随机推荐
- 九、持久层框架(MyBatis)
一.基于MyBatis的对象关系配置(基于XML方式的配置) 注: MyBatis不能像Hibernate那样,在实体类上配置上注解或者配置xml映射文件,系统启动后就可以自动创建表.因为MyBati ...
- IntelliJ IDEA下载及安装,破解
IntelliJ IDEA下载及安装,破解 百度百科:IDEA 全称IntelliJ IDEA,是java语言开发的集成环境,IntelliJ在业界被公认为最好的java开发工具之一,尤其在智能代码助 ...
- Xcode下的中文乱码问题
Xcode下的中文乱码问题 转载自:http://linyehui.me/2014/07/09/convert-gbk-to-utf8-on-mac.html =========== 问题原因 绝大部 ...
- ActiveMQ queue和topic,持久订阅和非持久订阅
消息的 destination 分为 queue 和 topic,而消费者称为 subscriber(订阅者).queue 中的消息只会发送给一个订阅者,而 topic 的消息,会发送给每一个订阅者. ...
- pickle file in matlab
Load pickle files in Matlab Posted on June 12, 2013 by xcorr http://xcorr.net/2013/06/12/load-pick ...
- 尚学堂java答案解析 第一章
本答案为本人个人编辑,仅供参考,如果读者发现,请私信本人或在下方评论,提醒本人修改 一.选择题: 1.C 解析:java为了安全,中并没有引入C语言的指针概念. 2.AD 解析:B:Java先通过ja ...
- jsp标签之jsp:setProperty用法
参考:http://blog.csdn.net/wanghaishanren/article/details/2047400
- 阿里云服务器上安装mysql的详细步骤
阿里云安装mysql (1)下载mysql安装包,去mysql官网下载对应的包 mysql数据库官方下载网址: https://downloads.mysql.com/archives/commu ...
- day040 数据库索引补充 存储过程 事务等
1.正确使用索引 视图: 关键词 view 视图是体格虚拟表 创建视图 : create view 视图名称 as sql语句; 例: create view t_view as select * f ...
- 什么是Java优先级队列(Priority Queue)?
PriorityQueue是一个基于优先级堆的无界队列.它的元素是按照自然顺序排序的.在创建元素的时候,我们给它一个一个负责排序的比较器.PriorityQueue不允许null值,因为 它们没有自然 ...