結果
問題 | No.251 大きな桁の復習問題(1) |
ユーザー |
![]() |
提出日時 | 2015-07-25 01:13:41 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 9 ms / 5,000 ms |
コード長 | 594 bytes |
コンパイル時間 | 1,324 ms |
コンパイル使用メモリ | 160,820 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-17 17:21:04 |
合計ジャッジ時間 | 2,224 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#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; }