結果
| 問題 |
No.251 大きな桁の復習問題(1)
|
| コンテスト | |
| ユーザー |
tubo28
|
| 提出日時 | 2015-07-25 01:26:58 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 5,000 ms |
| コード長 | 568 bytes |
| コンパイル時間 | 1,355 ms |
| コンパイル使用メモリ | 159,992 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-17 17:21:06 |
| 合計ジャッジ時間 | 2,275 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#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;
}
tubo28