結果
問題 | No.1243 約数加算 |
ユーザー |
![]() |
提出日時 | 2020-10-02 22:00:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,306 bytes |
コンパイル時間 | 1,830 ms |
コンパイル使用メモリ | 171,884 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-17 13:15:22 |
合計ジャッジ時間 | 2,826 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 RE * 1 |
ソースコード
#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); } } 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; }