結果
問題 |
No.1243 約数加算
|
ユーザー |
|
提出日時 | 2020-11-04 05:53:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 718 bytes |
コンパイル時間 | 866 ms |
コンパイル使用メモリ | 72,172 KB |
最終ジャッジ日時 | 2025-01-15 19:36:33 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <iostream> #include <vector> using lint = long long; void solve() { lint x, y; std::cin >> x >> y; std::vector<lint> ans; while (x != y) { int r = 60; while (true) { if (((y >> r) & 1) && ((~x >> r) & 1)) break; --r; } int l; for (l = 0; l < r; ++l) { if ((x >> l) & 1) break; } ans.push_back(1LL << l); x += (1LL << l); } std::cout << ans.size() << "\n"; for (auto a : ans) std::cout << a << " "; std::cout << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int q; std::cin >> q; while (q--) solve(); return 0; }