結果

問題 No.415 ぴょん
ユーザー tai96
提出日時 2016-09-04 23:28:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 358 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 62,264 KB
実行使用メモリ 412,288 KB
最終ジャッジ日時 2024-11-15 20:18:13
合計ジャッジ時間 15,821 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 4 TLE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>

int n, d;
std::set<int> s;
int cur, cnt;

int main() {
	std::cin >> n >> d;
	
	if (d == 1)std::cout << n << std::endl;
	else if (d == n - 1)std::cout << n << std::endl;
	else {
		while (s.find(cur) == s.end()) {
			s.insert(cur);
			cur = (cur + d) % n;
			++cnt;
		}

		std::cout << cnt - 1 << std::endl;
	}

	return 0;
}
0