結果

問題 No.643 Two Operations No.2
ユーザー convexineqconvexineq
提出日時 2021-03-03 19:49:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 225 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 53,096 KB
最終ジャッジ日時 2024-04-14 11:31:45
合計ジャッジ時間 1,945 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,012 KB
testcase_01 AC 37 ms
52,880 KB
testcase_02 AC 37 ms
52,336 KB
testcase_03 AC 36 ms
53,012 KB
testcase_04 AC 36 ms
52,880 KB
testcase_05 AC 37 ms
52,824 KB
testcase_06 AC 37 ms
52,728 KB
testcase_07 AC 37 ms
53,096 KB
testcase_08 AC 37 ms
52,612 KB
testcase_09 AC 37 ms
52,336 KB
testcase_10 AC 39 ms
52,188 KB
testcase_11 AC 37 ms
52,976 KB
testcase_12 AC 37 ms
52,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

x,y = map(int,input().split())
q = [(x,y,0)]
ans = 10
while q:
    x,y,c = q.pop()
    if x==y: ans = min(ans,c)
    if c >= 10: continue
    q.append((x+y,x-y,c+1))
    q.append((x+y,y-x,c+2))
print(ans if ans != 10 else -1)
0