結果
問題 |
No.1880 Many Ways
|
ユーザー |
|
提出日時 | 2022-03-17 17:08:56 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 968 bytes |
コンパイル時間 | 1,290 ms |
コンパイル使用メモリ | 95,332 KB |
実行使用メモリ | 6,816 KB |
最終ジャッジ日時 | 2024-10-01 13:55:31 |
合計ジャッジ時間 | 14,794 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include <cassert> #include <iostream> #include <vector> using namespace std; int main() { long long A; cin >> A; assert(0 <= A && A < (1LL << 40)); long long br = 0; vector<int> ab; bool fd = 0; for (int i = 40; i >= 0; --i) { if (A & (1LL << i)) { if (!fd) fd = 1; else ab.push_back(1); } else { if (fd) ab.push_back(0); } } if (A == 0) { cout << 2 << " " << 0 << endl; return 0; } else if (A == 1) { cout << 1 << " " << 0 << endl; return 0; } int d = 2, u1 = 3, u2 = 4; vector<pair<int, int>> V = {{1, d}, {1, u1}, {1, u2}}; for (int a : ab) { V.emplace_back(d, d + 3); V.emplace_back(u1, u1 + 3); V.emplace_back(u1, u2 + 3); V.emplace_back(u2, u1 + 3); V.emplace_back(u2, u2 + 3); if (a) V.emplace_back(d, u1 + 3), V.emplace_back(d, u2 + 3); A >>= 1; d += 3; u1 += 3; u2 += 3; } cout << u2 << " " << V.size() << endl; for (auto [a, b] : V) cout << a << " " << b << endl; }