QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#129173 | #6740. Function | Nicolas125841 | WA | 682ms | 249864kb | C++17 | 1.5kb | 2023-07-22 04:29:57 | 2023-07-22 04:29:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const int N = 20210926;
const int SB = 32;
vector<vector<ll>> stirl(SB + 1, vector<ll>(SB + 1, 0));
vector<ll> bell(SB+1, 0), pref(N+1);
vector<int> lp(N+1), pr;
void prep(){
for (int i=2; i <= N; ++i) {
if (lp[i] == 0) {
lp[i] = i;
pr.push_back(i);
}
for (int j = 0; i * pr[j] <= N; ++j) {
lp[i * pr[j]] = pr[j];
if (pr[j] == lp[i]) {
break;
}
}
}
for(int i = 1; i <= SB; i++){
stirl[i][i] = 1;
stirl[i][1] = 1;
}
for(int n = 2; n <= SB; n++){
for(int k = 2; k <= n; k++){
stirl[n][k] = (stirl[n-1][k-1] + k * stirl[n-1][k]) % mod;
}
}
for(int n = 1; n <= SB; n++){
for(int k = 1; k <= n; k++){
bell[n] += stirl[n][k];
}
bell[n] %= mod;
}
pref[0] = 0;
pref[1] = 1;
for(int i = 2; i <= N; ++i){
pref[i] = pref[i-1];
int ti = i;
int cnt = 0;
while(ti != 1){
cnt++;
ti /= lp[ti];
}
pref[i] += bell[cnt];
pref[i] %= mod;
}
}
int main(){
prep();
int n;
cin >> n;
ll ans = 0;
for(int i = 1; i <= n; i++){
ans += pref[i] - pref[i-1];
}
cout << ans << "\n";
}
详细
Test #1:
score: 100
Accepted
time: 660ms
memory: 249864kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 669ms
memory: 249208kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: -100
Wrong Answer
time: 682ms
memory: 248868kb
input:
100
output:
998
result:
wrong answer 1st numbers differ - expected: '949', found: '998'