HDU 6063 RXD and math(数论)

xiaoxiao2021-02-28  88

Description Input 多组用例,每组用例输入两个整数n和k,以文件尾结束输入(T<=10000,1<=n,k<=1e18) Output 对于每组用例,输出答案 Sample Input 10 10 Sample Output Case #1: 999999937 Solution Code

#include<cstdio> using namespace std; typedef long long ll; #define Mod 1000000007 int mod_pow(int a,int b,int mod) { int ans=1; while(b) { if(b&1)ans=(ll)ans*a%mod; a=(ll)a*a%mod; b>>=1; } return ans; } int main() { int Case=1; ll n,k; while(~scanf("%I64d%I64d",&n,&k)) { n%=Mod,k%=(Mod-1); printf("Case #%d: %d\n",Case++,mod_pow(n,k,Mod)); } }
转载请注明原文地址: https://www.6miu.com/read-55995.html

最新回复(0)