結果

問題 No.1243 約数加算
ユーザー milanis48663220milanis48663220
提出日時 2020-10-02 21:45:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,000 bytes
コンパイル時間 781 ms
コンパイル使用メモリ 85,580 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-23 04:32:43
合計ジャッジ時間 1,695 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    if(a == b){
        cout << 0 << endl;
        cout << endl;
        return;
    } 
    ll m = (a^b)&b;
    ll x = 0;
    for(int i = 60; i >= 0; i--){
        if(m&((ll)1<<i)){
            x = i;
            break;
        }
    }
    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();
}
0