結果
| 問題 |
No.1243 約数加算
|
| コンテスト | |
| ユーザー |
H20
|
| 提出日時 | 2021-04-13 10:36:42 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,319 bytes |
| コンパイル時間 | 159 ms |
| コンパイル使用メモリ | 82,208 KB |
| 実行使用メモリ | 76,672 KB |
| 最終ジャッジ日時 | 2024-06-29 11:04:00 |
| 合計ジャッジ時間 | 2,571 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 WA * 7 |
ソースコード
import math
T = int(input())
for _ in range(T):
A,B = map(int,input().split())
ANS = []
if len(format(A, 'b'))!=len(format(B, 'b')):
if len(format(A, 'b')) != len(format(B, 'b')):
for i in range(math.ceil(math.log2(A))):
if 2**i & A == 2**i:
A += 2**i
ANS.append(2**i)
while len(format(A, 'b'))!=len(format(B, 'b')):
ANS.append(A)
A*=2
AB = format(A, 'b')
for i in range(len(AB)):
AB = format(A, 'b')
BB = format(B, 'b')
if AB[i] != BB[i]:
ANS.append(2**(len(AB)-i-1))
A+=2**(len(AB)-i-1)
else:
AB = format(A, 'b')
BB = format(B, 'b')
for i in range(len(AB)):
if AB[i] != BB[i]:
for j in reversed(range(i,len(AB))):
AB = format(A, 'b')
if AB[i]=='1':
A += (2**(len(AB)-j-1))
ANS.append((2**(len(AB)-j-1)))
for i in reversed(range(len(AB))):
AB = format(A, 'b')
BB = format(B, 'b')
if AB[i] != BB[i]:
A += (2**(len(AB)-i-1))
ANS.append((2**(len(AB)-i-1)))
print(len(ANS))
print(*ANS)
H20