結果
| 問題 | No.3547 Rurumaru Function Problem |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-22 22:25:55 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 2,000 ms |
| コード長 | 839 bytes |
| 記録 | |
| コンパイル時間 | 335 ms |
| コンパイル使用メモリ | 85,120 KB |
| 実行使用メモリ | 52,352 KB |
| 最終ジャッジ日時 | 2026-05-22 22:26:06 |
| 合計ジャッジ時間 | 2,528 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
| 純コード判定待ち |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
n,m = list(map(int,input().split()))
n = list(map(int,list(bin(n)[2:])))
m = list(map(int,list(bin(m)[2:])))
c = 0
ans = 0
while len(n) and len(m):
c += 1
x,y = n.pop(),m.pop()
if c%2 == 0:
if y == x:
continue
elif y == 0 and x == 1:
print(-1)
exit()
else:
ans |= 1<<c
else:
if y == x:
if y == 1:
ans |= 1<<c
continue
elif y == 1 and x == 0:
print(-1)
exit()
while len(m):
c += 1
x = m.pop()
if c%2 == 1:
if x == 1:
print(-1)
exit()
elif x == 1:
ans |= 1<<c
while len(n):
c += 1
x = n.pop()
if c%2 == 0:
if x == 1:
print(-1)
exit()
print(ans>>1)