結果

問題 No.251 大きな桁の復習問題(1)
ユーザー machymachy
提出日時 2015-07-24 23:26:41
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 1,051 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 60,380 KB
実行使用メモリ 5,180 KB
最終ジャッジ日時 2023-08-22 16:54:52
合計ジャッジ時間 1,797 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,676 KB
testcase_01 AC 3 ms
4,660 KB
testcase_02 AC 3 ms
4,624 KB
testcase_03 AC 3 ms
4,752 KB
testcase_04 AC 3 ms
4,904 KB
testcase_05 AC 3 ms
4,752 KB
testcase_06 AC 3 ms
4,616 KB
testcase_07 AC 3 ms
4,556 KB
testcase_08 AC 3 ms
4,608 KB
testcase_09 AC 8 ms
5,180 KB
testcase_10 AC 8 ms
4,924 KB
testcase_11 AC 8 ms
4,924 KB
testcase_12 AC 8 ms
4,884 KB
testcase_13 AC 8 ms
4,972 KB
testcase_14 AC 8 ms
4,888 KB
testcase_15 AC 7 ms
4,984 KB
testcase_16 AC 8 ms
4,876 KB
testcase_17 AC 8 ms
4,880 KB
testcase_18 AC 8 ms
4,960 KB
testcase_19 AC 8 ms
5,016 KB
testcase_20 AC 3 ms
4,672 KB
testcase_21 AC 3 ms
4,604 KB
testcase_22 AC 3 ms
4,564 KB
testcase_23 AC 3 ms
4,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef long long LL;
const LL MOD = 129402307;

LL modpow(LL M, LL N){
    if(N <= 0) return 1;
    LL ans = modpow(M, N/2);
    ans = ans*ans%MOD;
    if(N%2 == 1) ans = ans*M%MOD;
    return ans;
}

int main(){
    LL N = 0, M = 0;
    string ns, ms;
    cin >> ns >> ms;
    vector<LL> base(100001);
    vector<LL> base2(100001);
    base[0] = 1;
    base2[0] = 1;
    for(int i = 1; i < base.size(); i++){
        base[i] = base[i-1] * 10 % MOD;
        base2[i] = base2[i-1] * 10 % (MOD-1);
    }
    for(int i = 0; i < ns.size(); i++){
        N += (LL)(ns[i]-'0') * base[ns.size()-i-1] % MOD;
        N %= MOD;
    }
    for(int i = 0; i < ms.size(); i++){
        M += (LL)(ms[i]-'0') * base2[ms.size()-i-1] % (MOD-1);
        M %= (MOD-1);
    }
    cerr << N << endl;
    cerr << M << endl;
    if(ms == "0"){
        cout << 1 << endl;
    }else if(N == 0){
        cout << 0 << endl;
    }else{
        cout << modpow(N, M) << endl;
    }
    
    return 0;
}
0