QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#289296 | #5817. 小学生数学题 | Michstabe | 20 | 975ms | 190488kb | C++14 | 718b | 2023-12-23 16:44:27 | 2023-12-23 16:44:27 |
Judging History
answer
#pragma once
#include<bits/stdc++.h>
#define maxn 150000
#define mod 998244353
#define FOR(x,y) for(int i=x;i<=y;i++)
using namespace std;
const int N = 2*1e7;
typedef long long ll;
ll n,k,cnt,ans,sum=1;
ll a[N],b[N],c[N];
inline ll ksm(ll x,ll y){
ll z=1;
while(y){
if(y&1) z=z*x%mod;
x=x*x%mod;y>>=1;
}return z;
}inline void ny(){
FOR(2,n){
if(!b[i]){
b[i]=c[++cnt]=i;a[i]=ksm(ksm(i,mod-2),k);
}for(int j=1;b[j]*i<=n&&j<=cnt&&b[j]<=c[i];j++){
c[b[j]*i]=b[j];
a[b[j]*i]=(a[b[j]]*a[i])%mod;
}
}
}
int main(){
cin>>n>>k;
a[1]=1; //逆元
ny();
FOR(1,n){
ans=(ans+sum*a[i]%mod),ans%=mod;
sum=sum*(i+1),sum%=mod;
}cout<<ans;
}
详细
Test #1:
score: 0
Time Limit Exceeded
input:
9450395 1
output:
result:
Test #2:
score: 0
Time Limit Exceeded
input:
8978812 1
output:
334565356
result:
Test #3:
score: 0
Time Limit Exceeded
input:
8944235 1
output:
982802915
result:
Test #4:
score: 10
Accepted
time: 863ms
memory: 171616kb
input:
7081118 3
output:
599009773
result:
ok single line: '599009773'
Test #5:
score: 10
Accepted
time: 975ms
memory: 190488kb
input:
7904241 3
output:
871243720
result:
ok single line: '871243720'
Test #6:
score: 0
Time Limit Exceeded
input:
9921275 3
output:
result:
Test #7:
score: 0
Time Limit Exceeded
input:
17575748 14135489
output:
result:
Test #8:
score: 0
Time Limit Exceeded
input:
19858362 14822524
output:
result:
Test #9:
score: 0
Time Limit Exceeded
input:
18848696 15530895
output:
result:
Test #10:
score: 0
Time Limit Exceeded
input:
17787945 13890407