結果

問題 No.1243 約数加算
ユーザー buey_tbuey_t
提出日時 2023-03-21 01:06:45
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 1,460 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 81,744 KB
実行使用メモリ 89,356 KB
最終ジャッジ日時 2023-10-18 18:15:59
合計ジャッジ時間 2,596 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
84,500 KB
testcase_01 AC 129 ms
84,500 KB
testcase_02 AC 130 ms
84,500 KB
testcase_03 AC 128 ms
84,496 KB
testcase_04 AC 161 ms
89,324 KB
testcase_05 AC 162 ms
89,324 KB
testcase_06 AC 163 ms
89,328 KB
testcase_07 AC 164 ms
89,356 KB
testcase_08 AC 164 ms
89,328 KB
testcase_09 AC 129 ms
84,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
    from heapq import heapify, heappop, heappush
    from bisect import bisect_left, bisect_right
    from copy import deepcopy
    import copy
    import random
    from collections import deque,Counter,defaultdict
    from itertools import permutations,combinations
    from decimal import Decimal,ROUND_HALF_UP
    #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    from functools import lru_cache, reduce
    #@lru_cache(maxsize=None)
    from operator import add,sub,mul,xor,and_,or_,itemgetter
    INF = 10**18
    mod1 = 10**9+7
    mod2 = 998244353
    
    #DecimalならPython
    
    
    '''
    
    
    
    '''
    
    for _ in range(int(input())):
        A,B = map(int, input().split())
        
        ans = []
        dgt = 0
        
        while A+pow(2,dgt) <= B:
            if (A>>dgt)&1:
                tmp = pow(2,dgt)
                A += tmp
                ans.append(tmp)
            dgt += 1
        
        for i in reversed(range(60)):
            if (B>>i)&1 and (~A>>i)&1:
                ans.append(pow(2,i))
                A += pow(2,i)
        
        print(len(ans))
        print(*ans)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0