結果

問題 No.3547 Rurumaru Function Problem
コンテスト
ユーザー LyricalMaestro
提出日時 2026-05-24 02:26:30
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 1,110 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 430 ms
コンパイル使用メモリ 20,696 KB
実行使用メモリ 15,484 KB
最終ジャッジ日時 2026-05-24 02:26:35
合計ジャッジ時間 3,997 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# https://yukicoder.me/problems/no/3547

from collections import deque

def main():
    N, M = map(int, input().split())

    n_array = []
    for _ in range(30):
        n_array.append(N % 2)
        N //= 2    
    m_array = []
    for _ in range(30):
        m_array.append(M % 2)
        M //= 2

    answer = 0
    for i in range(30):
        if i % 2 == 0:
            type_tuple = (n_array[i], m_array[i])
            if type_tuple == (0, 0):
                continue
            elif type_tuple == (0, 1):
                print(-1)
                return
            elif type_tuple == (1, 0):
                continue
            elif type_tuple == (1, 1):
                answer += 2 ** i
        else:
            type_tuple = (n_array[i], m_array[i])
            if type_tuple == (0, 0):
                continue
            elif type_tuple == (0, 1):
                answer += 2 ** i
            elif type_tuple == (1, 0):
                print(-1)
                return
            elif type_tuple == (1, 1):
                continue
    print(answer)






if __name__ == "__main__":
    main()
0