【2017 Multi-University Training Contest - Team 3】RXD and math

Link:

Description

Solution

发现1010mod(109+7)=999999937;
猜测答案是nk
写个快速幂;
注意对底数先取模;

NumberOf WA

1

Reviw

看到过的人那么多就应该想到找规律的.
大胆猜测

Code

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1e9+7;

int n,k;

int get_ans(int x,int y){
    int a = 1;
    x%=MOD;
    while (y){
        if (y&1) a = (a*x)%MOD;
        x=(x*x)%MOD;
        y>>=1;
    }
    return a;
}

main(){
    int kk = 0;
    while (~scanf("%lld%lld",&n,&k)){
        printf("Case #%lld: %lld\n",++kk,get_ans(n,k));
    }
    return 0;
}
posted @ 2017-10-04 18:44  AWCXV  阅读(140)  评论(0编辑  收藏  举报