結果
| 問題 |
No.181 A↑↑N mod M
|
| コンテスト | |
| ユーザー |
古寺いろは
|
| 提出日時 | 2015-04-06 00:04:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 404 bytes |
| コンパイル時間 | 1,354 ms |
| コンパイル使用メモリ | 165,908 KB |
| 実行使用メモリ | 814,684 KB |
| 最終ジャッジ日時 | 2024-07-04 02:18:10 |
| 合計ジャッジ時間 | 5,246 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 MLE * 1 -- * 3 |
| other | -- * 37 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
int dfs(int A, int N, int M){
if (M <= 1) return 0;
if (N == 0) return 1;
vector<int> v;
set<int> s;
long long temp = 1;
do{
s.insert(temp);
v.push_back((int)temp);
temp *= A;
temp %= M;
} while (s.count(temp) != 0);
return v[dfs(A, N - 1, v.size()) % M];
}
int main() {
int A, N, M;
cin >> A >> N >> M;
cout << dfs(A, N, M) << endl;
}
古寺いろは