hdu1420 Prepared for New Acmer (a^i mod n)

来源:互联网 发布:软件工程项目计划 编辑:程序博客网 时间:2024/06/06 13:24

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1420


#include <stdio.h>int main(){_int64 a,b,c,temp;int test;scanf("%d",&test);while(test--){scanf("%I64d %I64d %I64d",&a,&b,&c);a%=c;temp=1;while(b){if(b&1)temp=(temp*a)%c;a=(a*a)%c;b>>=1;}printf("%I64d\n",temp);}return 0;}