結果
問題 |
No.251 大きな桁の復習問題(1)
|
ユーザー |
![]() |
提出日時 | 2015-07-25 01:12:47 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 594 bytes |
コンパイル時間 | 1,523 ms |
コンパイル使用メモリ | 160,804 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-16 04:14:40 |
合計ジャッジ時間 | 3,282 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 RE * 6 |
ソースコード
#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; }