c语言sscanf函数的用法是什么
306
2022-08-31
FZU 1759 Super A^B mod C (欧拉函数,降幂公式)
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
There are multiply testcases. Each testcase, there is one line contains three integers A, B and C, separated by a single space.
Output
For each testcase, output an integer, denotes the result of A^B mod C.
Sample Input
3 2 42 10 1000
Sample Output
124
思路
一道指数非常可怕的题目,显然快速幂是无法直接求解的,这里我们需要用到降幂。
ABmod C=AB mod ϕ(C)+ϕ(C)mod C ,当且仅当 B>=ϕ(C)
ϕ
AC 代码
#include
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~