結果

問題 No.1243 約数加算
ユーザー rlangevinrlangevin
提出日時 2023-03-21 18:51:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,413 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 10,644 KB
最終ジャッジ日時 2023-10-18 18:30:58
合計ジャッジ時間 8,819 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

T = int(input())
for _ in range(T):
    A, B = map(int, input().split())
    ans = []
    nokori = 120
    flag = 1
    while A != B and flag:
        while 2 * A <= B:
            ans.append(A)
            A *= 2
            nokori -= 1
            
        if B - A <= nokori:
            ans.extend([1] * (B - A))
            break
                    
        ind = 0
        while A <= B:
            print(A, B, ans, sum(ans))
            two = 2 ** ind
            for i in range(ind + 1):
                if (B - A)//(2**i) <= nokori and (B - A)%(2**i)==0:
                    ans.extend([2**i] * ((B - A)//(2**i) ))
                    A += sum([2**i] * ((B - A)//(2**i) ))
                    break
            if A % two == 0:
                if A + A // two <= B:
                    ans.append(A // two)
                    A += A // two
                    nokori -= 1
                    ind = 0
                    break
                else:
                    ind += 1
            else:
                if A + two // 2 > B:
                    flag = 0
                    break
                A += two // 2
                nokori -= 1
                ans.append(two // 2)
        
        cnt = 0
        for i in range(60):
            if ((B - A) >> i) & 1:
                ans.append(1 << i)
                cnt += 1 << i              
    
            
    print(len(ans))
    print(*ans)
0