QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#709323 | #8023. The Journey of Geor Autumn | UESTC_DECAYALI# | AC ✓ | 150ms | 199196kb | C++20 | 867b | 2024-11-04 13:58:30 | 2024-11-04 13:58:30 |
Judging History
answer
#include<cstdio>
#include<iostream>
#define RI register int
#define CI const int&
using namespace std;
const int N=1e7+5,mod=998244353;
int n,k,g[N],sg[N],fact[N],ifac[N],inv[N];
inline int quick_pow(int x,int p=mod-2,int mul=1)
{
for (;p;p>>=1,x=1LL*x*x%mod) if (p&1) mul=1LL*mul*x%mod; return mul;
}
inline void init(CI n)
{
fact[0]=1; for (RI i=1;i<=n;++i) fact[i]=1LL*fact[i-1]*i%mod;
ifac[n]=quick_pow(fact[n]); for (RI i=n-1;i>=0;--i) ifac[i]=1LL*ifac[i+1]*(i+1)%mod;
inv[0]=1; for (RI i=1;i<=n;++i) inv[i]=1LL*ifac[i]*fact[i-1]%mod;
}
int main()
{
scanf("%d%d",&n,&k); init(n);
for (RI i=1;i<=k;++i) g[i]=1,sg[i]=(sg[i-1]+g[i])%mod;
for (RI i=k+1;i<=n;++i)
{
g[i]=1LL*(sg[i-1]-sg[i-k-1]+mod)*inv[i]%mod;
sg[i]=(sg[i-1]+g[i])%mod;
}
return printf("%d",1LL*g[n]*fact[n]%mod),0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 10056kb
input:
1 1
output:
1
result:
ok "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 10048kb
input:
1 2
output:
1
result:
ok "1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 10000kb
input:
1 3
output:
1
result:
ok "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 10036kb
input:
1 4
output:
1
result:
ok "1"
Test #5:
score: 0
Accepted
time: 1ms
memory: 10056kb
input:
2 1
output:
1
result:
ok "1"
Test #6:
score: 0
Accepted
time: 1ms
memory: 10096kb
input:
2 2
output:
2
result:
ok "2"
Test #7:
score: 0
Accepted
time: 0ms
memory: 10000kb
input:
2 3
output:
2
result:
ok "2"
Test #8:
score: 0
Accepted
time: 0ms
memory: 9972kb
input:
2 4
output:
2
result:
ok "2"
Test #9:
score: 0
Accepted
time: 1ms
memory: 9856kb
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: 0ms
memory: 9896kb
input:
3 3
output:
6
result:
ok "6"
Test #12:
score: 0
Accepted
time: 0ms
memory: 9852kb
input:
3 4
output:
6
result:
ok "6"
Test #13:
score: 0
Accepted
time: 0ms
memory: 9972kb
input:
4 1
output:
1
result:
ok "1"
Test #14:
score: 0
Accepted
time: 1ms
memory: 9996kb
input:
4 2
output:
10
result:
ok "10"
Test #15:
score: 0
Accepted
time: 1ms
memory: 10040kb
input:
4 3
output:
18
result:
ok "18"
Test #16:
score: 0
Accepted
time: 1ms
memory: 9836kb
input:
4 4
output:
24
result:
ok "24"
Test #17:
score: 0
Accepted
time: 1ms
memory: 10000kb
input:
99 50
output:
955866606
result:
ok "955866606"
Test #18:
score: 0
Accepted
time: 1ms
memory: 9996kb
input:
99 70
output:
296999003
result:
ok "296999003"
Test #19:
score: 0
Accepted
time: 1ms
memory: 10112kb
input:
1034 998
output:
637688669
result:
ok "637688669"
Test #20:
score: 0
Accepted
time: 0ms
memory: 10108kb
input:
1099 997
output:
712935289
result:
ok "712935289"
Test #21:
score: 0
Accepted
time: 0ms
memory: 10140kb
input:
10314 998
output:
224695890
result:
ok "224695890"
Test #22:
score: 0
Accepted
time: 1ms
memory: 11972kb
input:
10929 9974
output:
160291286
result:
ok "160291286"
Test #23:
score: 0
Accepted
time: 3ms
memory: 10852kb
input:
103124 99448
output:
695932649
result:
ok "695932649"
Test #24:
score: 0
Accepted
time: 3ms
memory: 14744kb
input:
109139 9937
output:
268916696
result:
ok "268916696"
Test #25:
score: 0
Accepted
time: 23ms
memory: 33720kb
input:
1031234 99238
output:
441457721
result:
ok "441457721"
Test #26:
score: 0
Accepted
time: 16ms
memory: 33416kb
input:
1091239 991237
output:
61047495
result:
ok "61047495"
Test #27:
score: 0
Accepted
time: 125ms
memory: 199132kb
input:
10000000 9982443
output:
224744113
result:
ok "224744113"
Test #28:
score: 0
Accepted
time: 150ms
memory: 199196kb
input:
9999977 5678901
output:
641748125
result:
ok "641748125"
Extra Test:
score: 0
Extra Test Passed