結果

問題 No.1243 約数加算
ユーザー hiro71687khiro71687k
提出日時 2023-03-03 07:07:15
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,071 bytes
コンパイル時間 6,564 ms
コンパイル使用メモリ 262,100 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 00:47:20
合計ジャッジ時間 7,778 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=double;
ld pie=3.14159265359;
ll mod=998244353;
long long inf=100000000000000001;
int main(){
    ll t;
    cin >> t;
    vector<ll>two(62,1);
    for (ll i = 1; i < two.size(); i++)
    {
        two[i]=two[i-1]*2;
    }
    for (ll o = 0; o < t; o++)
    {
        ll a,b;
        cin >> a >> b;
        ll x=b-a;
        ll now=0;
        for (ll i = 0; i <=61; i++)
        {
            if (a%two[i]==0)
            {
                now=max(now,i);
            }
        }
        vector<ll>ans;
        while (two[now]<x)
        {
            ans.push_back(two[now]);
            x-=two[now];
            now+=1;
        }
        for (ll i = 61; i >=0; i--)
        {
            if (two[i]&x)
            {
                ans.push_back(two[i]);
            }
        }
        cout << ans.size() << endl;
        for (ll i = 0; i < ans.size(); i++)
        {
            cout << ans[i]<< ' ';
        }
        cout << endl;
    }
    
}
0