結果
| 問題 |
No.1809 Divide NCK
|
| コンテスト | |
| ユーザー |
trineutron
|
| 提出日時 | 2022-01-14 21:38:28 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 2,000 ms |
| コード長 | 639 bytes |
| コンパイル時間 | 3,097 ms |
| コンパイル使用メモリ | 249,176 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-20 08:34:42 |
| 合計ジャッジ時間 | 4,227 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int64_t count(int64_t n, int64_t p)
{
if (n == 0)
{
return 0;
}
return n / p + count(n / p, p);
}
int main()
{
int64_t n, k, m;
cin >> n >> k >> m;
map<int64_t, int64_t> primes;
for (int64_t i = 2; i * i <= m; i++)
{
while (m % i == 0)
{
primes[i]++;
m /= i;
}
}
if (m > 1)
{
primes[m]++;
}
int64_t ans = 1e9;
for (auto &&[p, c] : primes)
{
ans = min(ans, (count(n, p) - count(k, p) - count(n - k, p)) / c);
}
cout << ans << endl;
return 0;
}
trineutron