結果

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

ソースコード

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;

	while (s.find(cur) == s.end()) {
		s.insert(cur);
		cur = (cur + d) % n;
		++cnt;
	}

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

	return 0;
}
0