RXD and math HDU

来源:互联网 发布:thinkphp5开发大型cms 编辑:程序博客网 时间:2024/05/22 00:34

这里写图片描述

Sample Input
10 10
Sample Output
Case #1: 999999937

打表找规律 快速幂

#include<cstdio>using namespace std;#define ll long longconst int mod=1e9+7;///注意取余ll pow(ll a,ll n){    ll text=1;    while (n)    {        if (n&1) text = (text%mod)*(a%mod)%mod;        a = (a%mod)*(a%mod)%mod;        n >>= 1;    }    return text;}int main(){    ll n,k;    int i=1;    while(~scanf("%lld%lld",&n,&k))    {        ll text=pow(n,k);        printf("Case #%d: %lld\n",i++,text);    }    return 0;}
原创粉丝点击