結果

問題 No.680 作れる数
ユーザー ckawatakckawatak
提出日時 2019-01-04 12:40:16
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 614 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 57,088 KB
最終ジャッジ日時 2024-11-23 23:09:46
合計ジャッジ時間 34,593 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 WA * 4 TLE * 11
権限があれば一括ダウンロードができます

ソースコード

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