結果

問題 No.3 ビットすごろく
コンテスト
ユーザー kpinkcat
提出日時 2022-10-13 13:37:51
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 626 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 439 ms
コンパイル使用メモリ 20,824 KB
実行使用メモリ 30,972 KB
最終ジャッジ日時 2026-03-13 05:04:35
合計ジャッジ時間 111,278 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 WA * 6 TLE * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
total = 1
now = 1

line = []
for i in range(1, N+1):
    b_num = '{0:b}'.format(i)
    c = 0
    for j in b_num:
        if j == "1":
            c += 1
    line.append(str(c))
    #print(c, b_num)
c = 1
while 1 :
    if now == N:
        print(c)
        break
    else:
        c += 1
        if int(line[now -1]) + now > N:
            if now - int(line[now -1]) <= 0:
                print(-1)
            else:
                now -= int(line[now -1])
                if str(now) in line[now-1]:
                    print(-1)
                    break

        else:
            now += int(line[now -1])
0