結果

問題 No.1243 約数加算
ユーザー ShibuyapShibuyap
提出日時 2020-10-06 19:56:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,136 bytes
コンパイル時間 2,027 ms
コンパイル使用メモリ 201,968 KB
実行使用メモリ 814,256 KB
最終ジャッジ日時 2023-09-27 08:51:57
合計ジャッジ時間 9,687 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 200005

int main() {
    int T; cin >> T;
    rep(_,T){
        ll a, b;
        cin >> a >> b;
        bitset<100> c(a);
        bitset<100> d(b);

        int ma = 0;
        rep(i,100){
            if(c[i]==0&&d[i]) ma = i;
        }

        vector<ll> ans;
        while(c[ma] == 0){
            rep(i,100){
                if(c[i]){
                    a += 1 << i;
                    ans.push_back(1<<i);
                    bitset<100> cc(a);
                    c = cc;
                    break;
                }
            }
        }

        drep(i,ma){
            if(d[i]){
                ans.push_back(1<<i);
            }
        }

        cout << ans.size() << endl;
        rep(i,ans.size()){
            if(i > 0) cout << ' ';
            cout << ans[i];
        }
        cout << endl;
    }
    return 0;
}
 
 
0