結果
問題 |
No.181 A↑↑N mod M
|
ユーザー |
|
提出日時 | 2015-04-07 21:20:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 863 bytes |
コンパイル時間 | 844 ms |
コンパイル使用メモリ | 90,696 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-04 10:55:55 |
合計ジャッジ時間 | 2,226 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 10 WA * 27 |
ソースコード
#include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> using namespace std; long long power(long long a, long long b, long long mod) { long long ret = 1; long long tmp = a; while(b > 0){ if(b & 1){ ret *= tmp; ret %= mod; } tmp *= tmp; tmp %= mod; b >>= 1; } return ret; } int main() { long long a, n, m; cin >> a >> n >> m; n %= m; long long ans = 1; for(int i=0; i<n; ++i) ans = power(a, ans, m); cout << ans << endl; return 0; }