結果
問題 |
No.415 ぴょん
|
ユーザー |
![]() |
提出日時 | 2019-01-05 20:51:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,537 bytes |
コンパイル時間 | 884 ms |
コンパイル使用メモリ | 102,756 KB |
実行使用メモリ | 398,208 KB |
最終ジャッジ日時 | 2024-11-23 23:32:57 |
合計ジャッジ時間 | 20,177 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 TLE * 9 |
ソースコード
#include <stdio.h> #include <iostream> #include <string> #include <vector> #include <set> #include <cmath> #include <stack> #include <algorithm> #include <iomanip> #include <map> #include <queue> #include <functional> #include <numeric> #include <chrono> #include <cstdlib> using ll = long long; using namespace std; const ll MOD = 1e9 + 7; #define REP(i, n) for (int(i) = 0; (i) < (n); ++(i)) #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) // bool operator<(const pair<int, int> &a, const pair<int, int> &b) // { // if (a.first == b.first) // return a.second < b.second; // return a.first < b.first; // }; /*unsigned int xor128(void) { static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123; unsigned int t = (x ^ (x << 11)); x = y; y = z; z = w; return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))); } unsigned int xor128rnd(unsigned int m) { return xor128() % m; }*/ /*bool operator<(const pair<int, int> &a, const pair<int, int> &b) { if (a.first == b.first) { return a.second < b.second; } return a.first < b.first; }*/ set<ll> st; int main(void) { cin.tie(0); ios::sync_with_stdio(false); ll N, D; cin >> N >> D; if (D == 1) { cout << N - 1 << endl; return 0; } int pos = 0; st.insert(pos); while (1) { pos = (pos + D) % N; if (st.find(pos) != st.end()) break; st.insert(pos); } cout << st.size() - 1 << endl; return 0; }