結果

問題 No.642 Two Operations No.1
ユーザー masamasa
提出日時 2018-02-02 21:31:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 297 bytes
コンパイル時間 741 ms
コンパイル使用メモリ 73,452 KB
実行使用メモリ 258,160 KB
最終ジャッジ日時 2023-08-30 02:02:56
合計ジャッジ時間 4,323 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>

using namespace std;

int main() {
	int n;
	cin >> n;

	set<int> s, t;
	s.insert(1);
	int ans = 0;
	while (s.count(n) == 0) {
		ans++;
		t.clear();
		for (auto x : s) {
			t.insert(x * 2);
			t.insert(x - 1);
		}
		s = t;
	}

	cout << ans << endl;
	return 0;
}
0