結果

問題 No.415 ぴょん
ユーザー 👑 yumechiyumechi
提出日時 2016-08-26 22:47:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 530 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 82,596 KB
実行使用メモリ 54,220 KB
最終ジャッジ日時 2024-04-25 21:38:21
合計ジャッジ時間 1,872 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 36 ms
52,884 KB
testcase_02 AC 35 ms
52,880 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 36 ms
52,268 KB
testcase_21 WA -
testcase_22 AC 34 ms
53,088 KB
testcase_23 WA -
testcase_24 AC 34 ms
53,080 KB
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n, d = map(int, input().split())
    if d == 1:
        print(n - 1)
        return
    elif d % n == 0:
        print(n // d - 1)
        return

    visited = set([])
    now, ans = 0, 0
    while True:
        visited |= set([now])
        t = now
        now = (n - (n % d) + d) % n
        ans += ((n - t) // d + 1) if (n - t) % d != 0 else (n - t) // d
        # print(visited, now, ans)
        if now in visited:
            ans -= 1
            break
    print(ans)


if __name__=="__main__":
    solve()
0