結果
問題 | No.1809 Divide NCK |
ユーザー | ytqm3 |
提出日時 | 2022-01-14 22:12:43 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 213 ms / 2,000 ms |
コード長 | 416 bytes |
コンパイル時間 | 157 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-11-20 11:09:15 |
合計ジャッジ時間 | 3,234 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 |
ソースコード
def primefact(m): res=[] i=2 while i*i<=m: if m%i!=0: i+=1 continue ex=0 while m%i==0: m//=i ex+=1 res.append([i,ex]) i+=1 if m!=1: res.append([m,1]) return res def f(n,m): res=0 while n>0: n//=m res+=n return res N,K,M=map(int,input().split()) ps=primefact(M) ans=10**18 for [p,e] in ps: ans=min(ans,(f(N,p)-f(K,p)-f(N-K,p))//e) print(ans)