結果

問題 No.3 ビットすごろく
ユーザー kpinkcat
提出日時 2022-10-13 13:37:51
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 626 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 17,824 KB
最終ジャッジ日時 2024-06-26 12:01:35
合計ジャッジ時間 6,979 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 TLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

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