結果

問題 No.1809 Divide NCK
ユーザー horitaka1999horitaka1999
提出日時 2022-01-15 10:56:50
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 368 bytes
コンパイル時間 1,101 ms
コンパイル使用メモリ 86,680 KB
実行使用メモリ 71,508 KB
最終ジャッジ日時 2023-08-13 14:02:32
合計ジャッジ時間 5,175 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,432 KB
testcase_01 AC 70 ms
71,296 KB
testcase_02 AC 70 ms
71,272 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 70 ms
71,144 KB
testcase_08 AC 71 ms
71,292 KB
testcase_09 WA -
testcase_10 AC 70 ms
71,264 KB
testcase_11 AC 70 ms
71,336 KB
testcase_12 AC 70 ms
71,188 KB
testcase_13 AC 71 ms
71,148 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 72 ms
71,312 KB
testcase_17 AC 72 ms
71,304 KB
testcase_18 AC 71 ms
71,284 KB
testcase_19 AC 72 ms
71,208 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 71 ms
71,204 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 71 ms
71,260 KB
testcase_26 WA -
testcase_27 AC 73 ms
71,332 KB
testcase_28 WA -
testcase_29 AC 71 ms
71,320 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 74 ms
71,088 KB
testcase_35 WA -
testcase_36 AC 71 ms
71,336 KB
testcase_37 AC 70 ms
71,392 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K,M = map(int,input().split())
def f(l,r,x):
    al = (l + pow(M,x) -1) // pow(M,x)
    al = max(al,1)
    ar = r //pow(M,x)
    if ar >= 1 and al <= ar:
        return ar - al + 1
    else:
        return 0
def g(l,r):
    x = 1
    res = 0
    while pow(M,x) <= r:
        res += f(l,r,x)
        x += 1
    return res

up = g(N-K+1,N)
down = g(1,K)
print(up-down)
0