結果

問題 No.1809 Divide NCK
ユーザー customaddonecustomaddone
提出日時 2022-01-14 21:45:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,248 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 82,696 KB
実行使用メモリ 63,336 KB
最終ジャッジ日時 2024-04-30 13:52:55
合計ジャッジ時間 2,976 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
61,620 KB
testcase_01 AC 42 ms
62,644 KB
testcase_02 AC 43 ms
61,984 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 46 ms
61,360 KB
testcase_08 AC 46 ms
62,080 KB
testcase_09 WA -
testcase_10 AC 48 ms
62,768 KB
testcase_11 AC 44 ms
62,428 KB
testcase_12 AC 43 ms
61,952 KB
testcase_13 AC 44 ms
62,308 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 44 ms
61,972 KB
testcase_17 AC 44 ms
62,228 KB
testcase_18 AC 43 ms
61,808 KB
testcase_19 AC 43 ms
61,304 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 45 ms
62,688 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 43 ms
61,776 KB
testcase_26 WA -
testcase_27 AC 43 ms
62,748 KB
testcase_28 WA -
testcase_29 AC 43 ms
62,000 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 43 ms
62,216 KB
testcase_35 WA -
testcase_36 AC 44 ms
62,284 KB
testcase_37 AC 44 ms
61,928 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque, Counter
from heapq import heapify, heappop, heappush
import math
from copy import deepcopy
from itertools import combinations, permutations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right

import sys

def input():
    return sys.stdin.readline().rstrip()
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getListGraph():
    return list(map(lambda x:int(x) - 1, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

mod = 10 ** 9 + 7
MOD = 998244353
# sys.setrecursionlimit(10000000)
inf = float('inf')
eps = 10 ** (-15)
dy = [0, 1, 0, -1]
dx = [1, 0, -1, 0]

#############
# Main Code #
#############

"""
x = 0なら余りは0
nCkは求められない どんな数か?
Mの因数はいくつあるか?という問題 分子と分母でMの個数を数えてみる
nCk = n! / (n - r)!r! とすると簡単
8*7*6*5*4*3*2*1/3*2*1 * 5*4*3*2*1
"""

N, K, M = getNM()

def calc(x, m):
    tar = m
    res = 0
    while tar <= x:
        res += x // tar
        tar *= m
    return res

print(calc(N, M) - calc(N - K, M) - calc(K, M))
0