結果

問題 No.680 作れる数
ユーザー ckawatakckawatak
提出日時 2019-01-04 12:40:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 614 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 51,456 KB
最終ジャッジ日時 2024-05-03 02:46:17
合計ジャッジ時間 4,225 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
16,384 KB
testcase_01 AC 33 ms
10,880 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 39 ms
10,752 KB
testcase_06 WA -
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from queue import Queue

N = int(input())

def bfs():
    step = 0
    s = 0
    t = 0
    
    que = Queue()
    que.put((step,s,t))

    while not que.empty():
        step,s,t = que.get()
        
        step = step % 2
        if step == 0:
            que.put((step+1,s,2*t))
        elif step == 1:
            if s+t+1 == N or s+t == N:
                print('YES')
                exit(0)
            elif N < s+t+1 or N < s+t:
                print('NO')
                exit(0)
            else:
                que.put((step+1,s+t+1,t+1))
                que.put((step+1,s+t,t))
    print('NO')

bfs()
0