結果

問題 No.251 大きな桁の復習問題(1)
ユーザー face4face4
提出日時 2018-11-03 13:10:46
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 662 bytes
コンパイル時間 590 ms
コンパイル使用メモリ 66,116 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-20 18:39:28
合計ジャッジ時間 1,503 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

typedef long long ll;
const ll mod = 129402307;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

int main(){
    string s, t;
    cin >> s >> t;

    ll n = 0, m = 0;
    for(int i = 0; i < s.length(); i++){
        n = n*10 + s[i]-'0';
        n %= mod;
    }

    for(int i = 0; i < t.length(); i++){
        m = m*10 + t[i]-'0';
        m %= (mod-1);
    }

    ll ans = modpow(n, m, mod);
    if(n == 0)  ans = 0;
    cout << ans << endl;

    return 0;
}
0