結果

問題 No.1243 約数加算
ユーザー DriceDrice
提出日時 2020-10-02 22:33:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 669 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 31,496 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-24 21:44:46
合計ジャッジ時間 1,965 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
long long ans[125];

int main(){
    int T;
    scanf("%d",&T);
    while(T--){
    long long a,b;
    scanf("%lld%lld",&a,&b);
    long long diff = b-a;
    //can use for now
    long long base = 1;
    int size = 0;
    while(base<=diff){
        long long nBase = base*2;
        if(a%nBase){
            diff -= base;
            a += base;
            ans[++size] = base;
        }
        base *= 2;
    }
    int len = 0;
    while(diff!=0){
        if(diff%2) ans[++size] = 1ll<<len;
        len++;
        diff /= 2;
    }
    printf("%d\n",size);
    for(int i = 1; i <= size; i++) printf("%lld ",ans[i]);
    printf("\n");
}
    return 0;
}
0