結果
| 問題 |
No.2896 Monotonic Prime Factors
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2024-09-25 15:42:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,157 ms / 2,000 ms |
| コード長 | 1,016 bytes |
| コンパイル時間 | 1,902 ms |
| コンパイル使用メモリ | 166,628 KB |
| 実行使用メモリ | 237,824 KB |
| 最終ジャッジ日時 | 2024-09-25 15:43:07 |
| 合計ジャッジ時間 | 21,966 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e7 + 5, mod = 998244353;
int x = 1, inv[N], g[N], f[N], cnt = 0;
int mypow(int a, int b) {
int ans = 1;
while (b) {
if (b & 1) {
ans = ans * a % mod;
}
a = a * a % mod;
b >>= 1;
}
return ans;
}
int C(int n, int m) {
return f[n] * g[m] % mod * g[n - m] % mod;
}
void Solve() {
int a, b;
cin >> a >> b;
for (int i = 2; i * i <= a; i++) {
while (a % i == 0) {
cnt++;
a /= i;
}
}
if (a != 1) {
cnt++;
}
if (cnt < b) {
cout << "0\n";
}
else cout << C(cnt - 1, b - 1) << "\n";
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
inv[1] = f[0] = g[0] = 1;
for (int i = 1; i <= 10000000; i++) {
f[i] = f[i - 1] * i % mod;
if (i > 1) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
g[i] = g[i - 1] * inv[i] % mod;
}
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
Solve();
}
return 0;
}
/*
.|.|.|.|.
4 * 3 * 2 * 1
*/
vjudge1