結果

問題 No.251 大きな桁の復習問題(1)
ユーザー tubo28tubo28
提出日時 2015-07-25 01:12:47
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 594 bytes
コンパイル時間 1,255 ms
コンパイル使用メモリ 145,328 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-23 04:04:21
合計ジャッジ時間 3,499 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 8 ms
4,380 KB
testcase_12 AC 8 ms
4,380 KB
testcase_13 AC 9 ms
4,380 KB
testcase_14 AC 9 ms
4,384 KB
testcase_15 AC 9 ms
4,380 KB
testcase_16 AC 9 ms
4,376 KB
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 9 ms
4,376 KB
testcase_19 AC 9 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll modstr(string const & s, ll m){
    ll a = 0;
    for(auto c:s) a = (c-'0'+a*10) % m;
    return a;
}

ll modpow(ll x, ll y, ll m){
    if(y==0) return 1;
    ll res = modpow(x,y/2,m);
    return res * res % m * (y&1 ? x : 1) % m;
};

ll modpow(string const & s, string const & t, ll m){
    assert(s != "0" && t != "0");
    ll N = modstr(s,m);
    if(N==0) return t == "0" ? 1 : 0;
    else return modpow(N,modstr(t,m-1),m);
}

int main(){
    string s,t;
    cin >> s >> t;
    cout << modpow(s,t,129402307) << endl;
}
0