結果
問題 | No.251 大きな桁の復習問題(1) |
ユーザー |
|
提出日時 | 2015-07-23 01:35:15 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 7 ms / 5,000 ms |
コード長 | 640 bytes |
コンパイル時間 | 434 ms |
コンパイル使用メモリ | 56,544 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-17 17:04:08 |
合計ジャッジ時間 | 1,832 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <iostream>using namespace std;typedef long long ll;const int MOD = 129402307;int mod(const string& S, int m){int res = 0;for(char x : S){res *= 10;res += x - '0';res %= m;}return res;}ll mod_pow(ll x, ll e, ll m){ll v = 1;for(;e;e>>=1){if(e & 1){v = (v * x) % m;}x = (x * x) % m;}return v;}int main(){string N, M;cin >> N >> M;if(N == "0"){cout << 0 << endl;return 0;}if(M == "0"){cout << 1 << endl;return 0;}int n = mod(N, MOD);if(n == 0){cout << 0 << endl;return 0;}int m = mod(M, MOD - 1);cout << mod_pow(n, m, MOD) << endl;return 0;}