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 ...
随机推荐
- Highcharts 环境配置
Highcharts 环境配置 本章节我们将为大家介绍如何在网页中使用 Highcharts. Highcharts 依赖于 jQuery,所以在加载 Highcharts 前必须先加载 jQuery ...
- Leetcode 969. 煎饼排序
969. 煎饼排序 显示英文描述 我的提交返回竞赛 用户通过次数134 用户尝试次数158 通过次数135 提交次数256 题目难度Medium 给定数组 A,我们可以对其进行煎饼翻转:我们选择 ...
- Python学习之路【第二篇】-pyc简介、Python常用的数据类型及其用法和常用运算符
1.pyc简介 python程序在运行时也有编译过程,编译后会产生.pyc文件.这是一种由python虚拟机执行的二进制文件(字节码),用于保存内存中PyCodeObject,以便加快程序的加载运行. ...
- TortioseSVN切换账号教程
TorioseSVN如果不记住用户名密码那么基本每样连接服务器的操作都要重新请求认证这很麻烦,所以我们一般选择记住用户认证信息. 但记住用户认证信息后以后每次登录都后台自动以该用户身份登录,不像QQ自 ...
- dynamic load jar and init spring
public class SpringLoader { private Map<String, Class<?>> classMap = new HashMap<> ...
- Qt画笔实现波形区域图
参考文章:https://blog.csdn.net/yuxing55555/article/details/79752978 效果图: void WareArea::paintEvent(QPain ...
- js 鼠标滚动 禁用 启用
function disabledMouseWheel() { var div = document.getElementById('divid'); if (div.addEventListener ...
- Win10系列:JavaScript 模板绑定
WinJS库模板提供了一种格式化显示多条数据的便捷方式,通过这种方式可以将模板与ListView或FlipView等控件结合使用以控制数据的显示格式.定义一个WinJS库模板的方法与定义WinJS库控 ...
- JAVA的环境变量配置(方式二)
1.想要成功配置Java的环境变量,那肯定就要安装JDK(JDK安装包在方式一中),才能开始配置的. 2.安装JDK 向导进行相关参数设置.如图: 3.正在安装程序的相关功能,如图: 4.选择安装的路 ...
- 每天CSS学习之text-decoration
text-decoration是CSS的一个属性,其作用是给文本装饰上划线.中间线.下划线或不装饰.其值如下所示: 1.none:不装饰任何线.该值是默认值.如下所示: p{ text-decorat ...