結果

問題 No.1880 Many Ways
コンテスト
ユーザー 👑 cologne
提出日時 2022-03-17 16:55:09
言語 C++17(clang)
(clang++ 22.1.8 + boost 1.92.0 + ACL)
コンパイル:
clang++ -O2 -lm -std=c++1z -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 637 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,784 ms
コンパイル使用メモリ 134,132 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-09-07 13:34:43
合計ジャッジ時間 12,652 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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