結果

問題 No.680 作れる数
ユーザー hang_hang_clnhang_hang_cln
提出日時 2018-05-07 20:38:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 542 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 15,024 KB
最終ジャッジ日時 2023-09-10 10:56:35
合計ジャッジ時間 4,342 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
15,024 KB
testcase_01 AC 17 ms
7,872 KB
testcase_02 AC 16 ms
7,784 KB
testcase_03 AC 16 ms
7,920 KB
testcase_04 AC 18 ms
7,764 KB
testcase_05 AC 25 ms
7,864 KB
testcase_06 AC 442 ms
8,492 KB
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 #

N = int(input())

# 1
s = 0
t = 0

NEXTqueue = [(0,0)] # 計算待ちキュー

can = False
while True:
    if len(NEXTqueue) == 0:
        break
    s,t = NEXTqueue.pop(0)
    # 2
    t *= 2
    
    # 3
    
    # 4
    #s += t
    if s+t == N or s+t+1 == N:
        can = True
        break
    if (s+t,t) not in NEXTqueue:        
        NEXTqueue.append((s+t, t))
    if (s+t+1, t+1) not in NEXTqueue:
        NEXTqueue.append((s+t+1, t+1))
    if NEXTqueue[-1][0] > N:
        break

if can:
    print('YES')
else:
    print('NO')
    
0