結果
問題 | No.1243 約数加算 |
ユーザー |
|
提出日時 | 2024-05-24 09:32:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 777 bytes |
コンパイル時間 | 2,114 ms |
コンパイル使用メモリ | 195,220 KB |
最終ジャッジ日時 | 2025-02-21 16:32:08 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h> #define INF 1000000001 #define MOD 1000000007 #define long long long #define all(x) x.begin(),x.end() using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while(t--) { long a,b; cin >> a >> b; int mx = -1; for(int i = 59; i>=0; i--) { if((b&(1LL<<i)) > (a&(1LL<<i))) { mx = i; break; } } vector<long> res; for(int i = 0; i<mx; i++) { if(a&(1LL<<i)) { res.push_back(1LL<<i); a+=1LL<<i; } } for(int i = 59; i>=0; i--) { if((b&(1LL<<i)) > (a&(1LL<<i))) { res.push_back(1LL<<i); a+=(1LL<<i); } } cout << res.size() << "\n"; for(int i = 0; i<res.size(); i++) cout << res[i] << " "; cout << "\n"; } return 0; }