結果

問題 No.251 大きな桁の復習問題(1)
コンテスト
ユーザー tubo28
提出日時 2015-07-25 01:26:58
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 5 ms / 5,000 ms
+ 19µs
コード長 568 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 837 ms
コンパイル使用メモリ 179,680 KB
実行使用メモリ 9,908 KB
最終ジャッジ日時 2026-10-04 18:05:31
合計ジャッジ時間 2,375 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll modstr(const string &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(const string &s, const string &t, ll m){
    assert(s != "0" || t != "0");
    ll N = modstr(s,m);
    return N==0 ? (t=="0"?1:0) : modpow(N,modstr(t,m-1),m);
}


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