QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#287981 | #5817. 小学生数学题 | Haoyue_06432 | 0 | 0ms | 0kb | C++14 | 717b | 2023-12-21 13:45:54 | 2023-12-21 13:45:55 |
answer
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e18
#define mod 998244353
using namespace std;
ll n,m,ans1=1,inv[maxn],zs[maxn],cnt,ans;
bool bj[maxn];
ll ksm(ll x,ll y)
{
ll ans=1;
while(y)
{
if(y%2==1)ans=(ans*x)%mod;
x=(x*x)%mod;
y/=2;
}
return ans;
}
int main()
{
cin>>n>>m;
inv[1]=1;
for(int i=2;i<=n;i++)
{
if(!bj[i])
{
bj[i]=true;
inv[i]=ksm(ksm(i,m),mod-2);
for(int j=1;j<=cnt&&zs[j]*i<=n;j++)
{
bj[zs[j]*i]=true;
inv[zs[j]*i]=(inv[zs[j]]*inv[i])%mod;
}
zs[++cnt]=i;
}
}
for(int i=1;i<=n;i++)
{
ans1=(ans1*i)%mod;
ans=(ans+ans1*inv[i]%mod)%mod;
}
cout<<ans;
return 0;
}
/*
*/
详细
Test #1:
score: 0
Runtime Error
input:
9450395 1
output:
result:
Test #2:
score: 0
Runtime Error
input:
8978812 1
output:
result:
Test #3:
score: 0
Runtime Error
input:
8944235 1
output:
result:
Test #4:
score: 0
Runtime Error
input:
7081118 3
output:
result:
Test #5:
score: 0
Runtime Error
input:
7904241 3
output:
result:
Test #6:
score: 0
Runtime Error
input:
9921275 3
output:
result:
Test #7:
score: 0
Runtime Error
input:
17575748 14135489
output:
result:
Test #8:
score: 0
Runtime Error
input:
19858362 14822524
output:
result:
Test #9:
score: 0
Runtime Error
input:
18848696 15530895
output:
result:
Test #10:
score: 0
Runtime Error
input:
17787945 13890407