結果
| 問題 |
No.1243 約数加算
|
| コンテスト | |
| ユーザー |
kibuna
|
| 提出日時 | 2020-10-02 22:05:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,423 bytes |
| コンパイル時間 | 1,851 ms |
| コンパイル使用メモリ | 173,040 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-17 13:28:52 |
| 合計ジャッジ時間 | 2,342 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int t;
cin >> t;
vector<lint> a(t), b(t);
for (int i = 0; i < t; ++i) {
cin >> a[i] >> b[i];
}
for (int i = 0; i < t; ++i) {
int nb = 64 - __builtin_clzll(b[i]);
int tp = -1;
lint curr = a[i];
vector<lint> res;
for (int j = nb - 1; j >= 0; --j) {
if ((b[i] & 1LL << j) && !(a[i] & 1LL << j)) {
tp = j;
break;
}
}
// assert(tp != -1);
for (int j = 0; j < tp; ++j) {
if (a[i] & 1LL << j) {
a[i] += 1LL << j;
res.push_back(1LL << j);
}
}
if (!(a[i] & 1LL << tp)) {
a[i] += 1LL << tp;
res.push_back(1LL << tp);
}
for (int j = tp - 1; j >= 0; --j) {
if ((b[i] & 1LL << j) && !(a[i] & 1LL << j)) {
a[i] += 1LL << j;
res.push_back(1LL << j);
}
}
cout << res.size() << "\n";
for (auto &r : res) {
cout << r << " ";
assert(curr % r == 0);
curr += r;
}
assert(curr == b[i]);
cout << endl;
}
return 0;
}
kibuna