結果
問題 | No.613 Solitude by the window |
ユーザー |
![]() |
提出日時 | 2017-12-13 19:35:06 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 665 bytes |
コンパイル時間 | 1,430 ms |
コンパイル使用メモリ | 90,324 KB |
実行使用メモリ | 103,872 KB |
最終ジャッジ日時 | 2024-12-14 10:06:01 |
合計ジャッジ時間 | 25,143 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 6 WA * 15 |
ソースコード
#include <iostream> #include <iomanip> #include <cstring> #include <algorithm> #include <math.h> #include <queue> #include <functional> #include <map> #include <vector> #include <string> using namespace std; typedef long long ll; ll n, m; ll a[2000000]; map<ll, ll> mp; int main(void){ cin >> n >> m; for (int i = 0; i <= 1000000; i++) a[i] = -1; a[0] = (2 * (2 + 4)) % m; mp[a[0]] = 1; ll cnt = 1; for (int i = 1; i <= 1400000; i++){ a[i] = (a[i - 1] * (a[i - 1] + 4)) % m; if (mp[a[i]] == 1) break; mp[a[i]] = 1; cnt++; } if (n%cnt == 0) cout << a[0] << endl; else cout << a[n%cnt - 1] << endl; }