結果

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

ソースコード

diff #

N = int(input())
now = 1

line = []
trace = []
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(c)
    #print(c, b_num)
c = 1
while 1 :
    if now == N:
        print(c)
        #print(trace)
        break
    else:
        c += 1
        if line[now -1] + now > N:
            if now - line[now -1] <= 0:
                print(-1)
            else:
                now -= line[now -1]
                if str(now) in trace:
                    print(-1)
                    break

        else:
            trace.append(now)
            now += line[now -1]
            
0