結果

問題 No.1880 Many Ways
コンテスト
ユーザー cologne
提出日時 2022-03-17 16:55:09
言語 C++17(clang)
(clang++ 22.1.2 + boost 1.89.0)
コンパイル:
clang++ -O2 -lm -std=c++1z -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 637 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,172 ms
コンパイル使用メモリ 142,836 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-17 15:09:45
合計ジャッジ時間 13,346 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <functional>
#include <iostream>
#include <optional>
#include <vector>
#include <atcoder/modint>

using namespace std;

int main()
{
	long long A;
	cin >> A;
	vector<pair<int, int>> V;
	if (A == 0)
	{
		cout << 2 << " " << 0 << endl;
		return 0;
	}
	else if (A == 1)
	{
		cout << 1 << " " << 0 << endl;
		return 0;
	}
	int u = 1, d = 1;
	while (A != 1)
	{
		int nu = u + 2, nd = u + 1;
		V.emplace_back(u, nu);
		V.emplace_back(u, nu);
		V.emplace_back(d, nd);
		if (A & 1)
			V.emplace_back(d, nu);
		A >>= 1;
		u = nu, d = nd;
	}
	cout << u << " " << V.size() << endl;
	for (auto [a, b] : V)
		cout << a << " " << b << endl;
}
0