結果
| 問題 |
No.1243 約数加算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-06 09:58:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 760 bytes |
| コンパイル時間 | 1,803 ms |
| コンパイル使用メモリ | 194,968 KB |
| 最終ジャッジ日時 | 2025-01-15 02:59:25 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
auto solve = [&] () {
vector<long long> ans;
long long a, b;
cin >> a >> b;
for (int i = 0; i < 60; i++) {
long long x = 1LL << i;
long long y = 1LL << (i + 1);
if (a % y != 0 && (a + x) <= b) {
a += x;
ans.push_back(x);
}
}
for (int i = 59; i >= 0; i--) {
long long x = 1LL << i;
if (a + x <= b) {
a += x;
ans.push_back(x);
}
}
assert(a == b);
cout << ans.size() << '\n';
for (int i = 0; i < (int) ans.size(); i++) {
if (i > 0) cout << " ";
cout << ans[i];
}
cout << '\n';
};
int t;
cin >> t;
while (t--) solve();
return 0;
}