結果
| 問題 |
No.2896 Monotonic Prime Factors
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2024-09-25 10:49:10 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 84 ms / 2,000 ms |
| コード長 | 1,087 bytes |
| コンパイル時間 | 6,084 ms |
| コンパイル使用メモリ | 275,156 KB |
| 実行使用メモリ | 27,520 KB |
| 最終ジャッジ日時 | 2024-09-25 10:49:23 |
| 合計ジャッジ時間 | 8,675 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int N = 1e5 + 10, M = 2e6 + 10, P = 998244353;
vector<int> primes;
int cnt[N], inv[M], fact[M], invFact[M];
int C(int n, int m) {
if(m < 0 || m > n) return 0;
return fact[n] * (i64)invFact[m] % P * invFact[n - m] % P;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
for(int i = 2; i < N; i ++) {
if(!cnt[i]) {
cnt[i] = 1;
primes.push_back(i);
}
for(int j : primes) {
if((i64)i * j >= N) break;
cnt[i * j] = cnt[i] + 1;
if(i % j == 0) break;
}
}
inv[1] = fact[0] = fact[1] = invFact[0] = invFact[1] = 1;
for(int i = 2; i < M; i ++) {
inv[i] = (P - P / i) * (i64)inv[P % i] % P;
fact[i] = fact[i - 1] * (i64)i % P;
invFact[i] = invFact[i - 1] * (i64)inv[i] % P;
}
int q;
cin >> q;
int tot = 0;
for(int i = 1, x, k; i <= q; i ++) {
cin >> x >> k;
tot += cnt[x];
cout << C(tot - 1, tot - k) << "\n";
}
}
vjudge1