結果

問題 No.680 作れる数
コンテスト
ユーザー ckawatak
提出日時 2019-01-04 12:40:16
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 614 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 438 ms
コンパイル使用メモリ 20,696 KB
実行使用メモリ 97,244 KB
最終ジャッジ日時 2026-05-17 17:16:27
合計ジャッジ時間 5,382 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 4 TLE * 1 -- * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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