結果

問題 No.2241 Reach 1
ユーザー first_vilfirst_vil
提出日時 2023-03-10 22:23:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 785 bytes
コンパイル時間 1,894 ms
コンパイル使用メモリ 81,480 KB
実行使用メモリ 53,452 KB
最終ジャッジ日時 2023-10-18 08:05:13
合計ジャッジ時間 5,109 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,452 KB
testcase_01 AC 39 ms
53,452 KB
testcase_02 AC 39 ms
53,452 KB
testcase_03 AC 39 ms
53,452 KB
testcase_04 AC 39 ms
53,452 KB
testcase_05 AC 39 ms
53,452 KB
testcase_06 AC 38 ms
53,452 KB
testcase_07 AC 39 ms
53,452 KB
testcase_08 AC 39 ms
53,452 KB
testcase_09 AC 38 ms
53,452 KB
testcase_10 AC 38 ms
53,452 KB
testcase_11 AC 37 ms
53,452 KB
testcase_12 AC 38 ms
53,452 KB
testcase_13 AC 39 ms
53,452 KB
testcase_14 AC 38 ms
53,452 KB
testcase_15 AC 38 ms
53,452 KB
testcase_16 AC 38 ms
53,452 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

int1 = lambda x: int(x) - 1

# input = lambda: sys.stdin.buffer.readline()
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
i1 = lambda: int1(input())
mi = lambda: map(int, input().split())
mi1 = lambda: map(int1, input().split())
li = lambda: list(mi())
li1 = lambda: list(mi1())
lli = lambda n: [li() for _ in range(n)]

INF = float("inf")
# mod = int(1e9 + 7)
mod = 998244353


def f(n):
    if n == 1:
        return 0
    res = INF
    m = 0
    for j in range(32):
        if n == (1 << j):
            res = min(res, 1)
        if (1 << j) > n and ((1 << j) - 1) % n == 0:
            res = min(res, 2)
        if n % (1 << j) == 0:
            m = max(m, j)
    if m > 0:
        res = min(res, 1 + f(n >> m))
    return res


print(f(ii()))
0