結果
問題 |
No.251 大きな桁の復習問題(1)
|
ユーザー |
|
提出日時 | 2018-03-10 05:52:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 668 bytes |
コンパイル時間 | 1,267 ms |
コンパイル使用メモリ | 160,920 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-11 21:10:47 |
合計ジャッジ時間 | 2,394 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 WA * 1 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; const ll mod = 129402307; string N, M; ll mod_pow(ll x, ll n, ll mod) { if (n == 0) return 1; ll res = mod_pow(x * x % mod, n / 2, mod); if (n & 1) res = res * x % mod; return res; } int main() { cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(10); cin >> N >> M; ll n = 0; for (int i = 0; i < N.size(); i++) { n = (n * 10 + N[i] - '0') % mod; } ll m = 0; for (int i = 0; i < M.size(); i++) { m = (m * 10 + M[i] - '0') % (mod - 1); } cout << (n == 0 ? 0 : mod_pow(n, m, mod)) << endl; return 0; }