fzu 1759 Super A^B mod C
2017-08-17 15:54
405 查看
题目链接
//#include<bits/stdc++.h> #include<iostream> #include<string> #include<cstring> using namespace std; typedef long long LL; LL qpow(LL x,LL n,LL mod) //求x^n%mod { LL ret=1; for(; n; n>>=1) { if(n&1) ret=ret*x%mod; x=x*x%mod; } return ret; } LL Eular(LL n) { LL ret=n; for(LL i=2; i*i<= n; i++) if(n%i==0) { ret-=ret/i; while(n%i==0) n/= i; } if(n>1) ret-=ret/n; return ret; } LL A,C; char B[1000005]; int main() { while(~scanf("%lld%s%lld",&A,B,&C)) { LL ans,a=A; LL phiC=Eular(C); int lenB=strlen(B); if(lenB>10) { LL t1=0; for(int i=0;i<lenB;i++) t1=(t1*10+B[i]-'0')%phiC; t1+=phiC; ans=qpow(A,t1,C); } else { LL b=0; for(int i=0;i<lenB;i++) b=b*10+B[i]-'0'; ans=qpow(A,b,C); } printf("%lld\n",ans); } }
相关文章推荐
- Super A^B mod C [FZU 1759]
- FZU 1759 Super A^B mod C (欧拉函数,快速幂,降幂公式)
- FZU - 1759 Super A^B mod C 降幂公式
- FZU 1759 Super A^B mod C
- FZU 1759 Super A^B mod C (欧拉降幂)
- FZU1759 Super A^B mod C
- FZU 1759-Super A^B mod C(快速幂+大整数取模+欧拉函数)
- FZU Problem 1759 Super A^B mod C(幂次循环节+快速乘法)
- Super A^B mod C FZU - 1759(欧拉降幂+快速密码)
- fzu - Problem 1759 Super A^B mod C
- FZU 1759 Super A^B mod C (快速幂+指数循环节)
- FZU1759Super A^B mod C(快速幂取模) 公式
- FZU 1759-Super A^B mod C(指数循环节)
- FZU-1759 Super A^B mod C
- FZU 1759-Super A^B mod C (快速幂+欧拉降幂+欧拉函数)
- FZU 1759 Super A^B mod C(数论)
- Super A^B mod C - FZU - 1759 - 降幂公式
- FZU 1759 Super A^B mod C (欧拉函数,降幂公式)
- FZU - 1759_Super A^B mod C_Euler降幂公式&&求phi(n)模板题
- FZU_1759 Super A^B mod C