QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#405146 | #8023. The Journey of Geor Autumn | Tomato_Fish# | AC ✓ | 189ms | 159992kb | C++14 | 854b | 2024-05-05 12:07:13 | 2024-05-05 12:07:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
const int mod=998244353;
const int N=1e7+100;
int mi(int x,int t){
int d=1;
while(t){
if(t%2) d=(ll)d*x%mod;
x=(ll)x*x%mod;t/=2;
}
return d;
}
int ni(int x) {return mi(x,mod-2);}
int f[N],fl[N],nf[N],Ni[N];
int main()
{
int n,K;
scanf("%d%d",&n,&K);
fl[0]=1;for(int i=1;i<=n;i++) fl[i]=(ll)fl[i-1]*i%mod;
nf[n]=ni(fl[n]);for(int i=n-1;i>=0;i--) nf[i]=(ll)nf[i+1]*(i+1)%mod;
for(int i=1;i<=n;i++) Ni[i]=(ll)fl[i-1]*nf[i]%mod;
for(int i=1;i<=K;i++) f[i]=Ni[n];
int Sum=0;
for(int i=1;i<=n;i++){
if(i-K-1>=1) Sum=(Sum-(ll)f[i-K-1]*Ni[n-(i-K-1)]%mod+mod)%mod;
f[i]=(f[i]+Sum)%mod;
Sum=(Sum+(ll)f[i]*Ni[n-i])%mod;
}
printf("%d\n",(ll)f[n]*fl[n]%mod);
// dfsdkfjsdklfjklsdjf
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 9992kb
input:
1 1
output:
1
result:
ok "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 9976kb
input:
1 2
output:
1
result:
ok "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 9848kb
input:
1 3
output:
1
result:
ok "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 9864kb
input:
1 4
output:
1
result:
ok "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 10032kb
input:
2 1
output:
1
result:
ok "1"
Test #6:
score: 0
Accepted
time: 0ms
memory: 10036kb
input:
2 2
output:
2
result:
ok "2"
Test #7:
score: 0
Accepted
time: 1ms
memory: 9844kb
input:
2 3
output:
2
result:
ok "2"
Test #8:
score: 0
Accepted
time: 1ms
memory: 10028kb
input:
2 4
output:
2
result:
ok "2"
Test #9:
score: 0
Accepted
time: 0ms
memory: 9976kb
input:
3 1
output:
1
result:
ok "1"
Test #10:
score: 0
Accepted
time: 1ms
memory: 10036kb
input:
3 2
output:
4
result:
ok "4"
Test #11:
score: 0
Accepted
time: 1ms
memory: 10040kb
input:
3 3
output:
6
result:
ok "6"
Test #12:
score: 0
Accepted
time: 0ms
memory: 9968kb
input:
3 4
output:
6
result:
ok "6"
Test #13:
score: 0
Accepted
time: 1ms
memory: 9908kb
input:
4 1
output:
1
result:
ok "1"
Test #14:
score: 0
Accepted
time: 1ms
memory: 10028kb
input:
4 2
output:
10
result:
ok "10"
Test #15:
score: 0
Accepted
time: 1ms
memory: 9932kb
input:
4 3
output:
18
result:
ok "18"
Test #16:
score: 0
Accepted
time: 0ms
memory: 10036kb
input:
4 4
output:
24
result:
ok "24"
Test #17:
score: 0
Accepted
time: 0ms
memory: 9976kb
input:
99 50
output:
955866606
result:
ok "955866606"
Test #18:
score: 0
Accepted
time: 2ms
memory: 9988kb
input:
99 70
output:
296999003
result:
ok "296999003"
Test #19:
score: 0
Accepted
time: 0ms
memory: 9872kb
input:
1034 998
output:
637688669
result:
ok "637688669"
Test #20:
score: 0
Accepted
time: 0ms
memory: 9992kb
input:
1099 997
output:
712935289
result:
ok "712935289"
Test #21:
score: 0
Accepted
time: 0ms
memory: 10080kb
input:
10314 998
output:
224695890
result:
ok "224695890"
Test #22:
score: 0
Accepted
time: 2ms
memory: 9924kb
input:
10929 9974
output:
160291286
result:
ok "160291286"
Test #23:
score: 0
Accepted
time: 4ms
memory: 12388kb
input:
103124 99448
output:
695932649
result:
ok "695932649"
Test #24:
score: 0
Accepted
time: 4ms
memory: 10420kb
input:
109139 9937
output:
268916696
result:
ok "268916696"
Test #25:
score: 0
Accepted
time: 18ms
memory: 22660kb
input:
1031234 99238
output:
441457721
result:
ok "441457721"
Test #26:
score: 0
Accepted
time: 24ms
memory: 28916kb
input:
1091239 991237
output:
61047495
result:
ok "61047495"
Test #27:
score: 0
Accepted
time: 184ms
memory: 159992kb
input:
10000000 9982443
output:
224744113
result:
ok "224744113"
Test #28:
score: 0
Accepted
time: 189ms
memory: 159972kb
input:
9999977 5678901
output:
641748125
result:
ok "641748125"
Extra Test:
score: 0
Extra Test Passed