結果
問題 | No.1243 約数加算 |
ユーザー | milanis48663220 |
提出日時 | 2020-10-02 21:51:25 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,013 bytes |
コンパイル時間 | 886 ms |
コンパイル使用メモリ | 85,496 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-23 04:44:55 |
合計ジャッジ時間 | 1,835 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 3 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 3 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,376 KB |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <set> #include <map> using namespace std; typedef long long ll; ll N; int K; ll A[100]; void solve(){ ll a, b; cin >> a >> b; vector<ll> ans; ll m = (a^b)&b; ll x = 0; for(int i = 60; i >= 0; i--){ if(m&((ll)1<<i)){ x = i; break; } } if(a%2 == 0){ a++; ans.push_back(1); } for(int i = 0; i < x; i++){ if(a&((ll)1<<i)){ a += ((ll)1<<i); ans.push_back((ll)1<<i); } } for(int i = x-1; i >= 0; i--){ if(b&((ll)1<<i)){ ans.push_back((ll)1<<i); } } cout << ans.size() << endl; for(ll i : ans) cout << i << ' '; cout << endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int t; cin >> t; for(int i = 0; i < t; i++) solve(); cout << ((ll)1<<60) << endl; }