QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#406254 | #8023. The Journey of Geor Autumn | Baiyu0123 | AC ✓ | 120ms | 120832kb | C++14 | 676b | 2024-05-06 23:57:36 | 2024-05-06 23:57:36 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e7+100,mod=998244353;
int fac[maxn],inv[maxn],f[maxn];
int qpow(int x,int y) {
ll ret=1,bas=x;
while (y) {
if (y&1) ret=ret*bas%mod;
bas=bas*bas%mod;
y>>=1;
}
return ret;
}
int main() {
fac[0]=1;
for (int i=1;i<maxn;i++) fac[i]=1ll*fac[i-1]*i%mod;
int INV=qpow(fac[maxn-1],mod-2);
for (int i=maxn-1;i>=1;i--) {
inv[i]=1ll*fac[i-1]*INV%mod;
INV=1ll*INV*i%mod;
}
int n,k;
cin>>n>>k;
for (int i=1;i<=k;i++) f[i]=1;
for (int i=k+1,sum=k;i<=n;i++) {
f[i]=1ll*sum*inv[i]%mod;
sum=(0ll+sum+f[i]-f[i-k]+mod)%mod;
}
cout<<1ll*f[n]*fac[n]%mod;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 83ms
memory: 82900kb
input:
1 1
output:
1
result:
ok "1"
Test #2:
score: 0
Accepted
time: 82ms
memory: 83588kb
input:
1 2
output:
1
result:
ok "1"
Test #3:
score: 0
Accepted
time: 90ms
memory: 82664kb
input:
1 3
output:
1
result:
ok "1"
Test #4:
score: 0
Accepted
time: 82ms
memory: 83528kb
input:
1 4
output:
1
result:
ok "1"
Test #5:
score: 0
Accepted
time: 83ms
memory: 82420kb
input:
2 1
output:
1
result:
ok "1"
Test #6:
score: 0
Accepted
time: 83ms
memory: 82852kb
input:
2 2
output:
2
result:
ok "2"
Test #7:
score: 0
Accepted
time: 75ms
memory: 82700kb
input:
2 3
output:
2
result:
ok "2"
Test #8:
score: 0
Accepted
time: 79ms
memory: 83732kb
input:
2 4
output:
2
result:
ok "2"
Test #9:
score: 0
Accepted
time: 71ms
memory: 82384kb
input:
3 1
output:
1
result:
ok "1"
Test #10:
score: 0
Accepted
time: 78ms
memory: 81876kb
input:
3 2
output:
4
result:
ok "4"
Test #11:
score: 0
Accepted
time: 92ms
memory: 83028kb
input:
3 3
output:
6
result:
ok "6"
Test #12:
score: 0
Accepted
time: 83ms
memory: 83192kb
input:
3 4
output:
6
result:
ok "6"
Test #13:
score: 0
Accepted
time: 79ms
memory: 83712kb
input:
4 1
output:
1
result:
ok "1"
Test #14:
score: 0
Accepted
time: 79ms
memory: 82872kb
input:
4 2
output:
10
result:
ok "10"
Test #15:
score: 0
Accepted
time: 83ms
memory: 83780kb
input:
4 3
output:
18
result:
ok "18"
Test #16:
score: 0
Accepted
time: 83ms
memory: 82668kb
input:
4 4
output:
24
result:
ok "24"
Test #17:
score: 0
Accepted
time: 91ms
memory: 82592kb
input:
99 50
output:
955866606
result:
ok "955866606"
Test #18:
score: 0
Accepted
time: 79ms
memory: 83560kb
input:
99 70
output:
296999003
result:
ok "296999003"
Test #19:
score: 0
Accepted
time: 83ms
memory: 81832kb
input:
1034 998
output:
637688669
result:
ok "637688669"
Test #20:
score: 0
Accepted
time: 95ms
memory: 82560kb
input:
1099 997
output:
712935289
result:
ok "712935289"
Test #21:
score: 0
Accepted
time: 87ms
memory: 81920kb
input:
10314 998
output:
224695890
result:
ok "224695890"
Test #22:
score: 0
Accepted
time: 91ms
memory: 83168kb
input:
10929 9974
output:
160291286
result:
ok "160291286"
Test #23:
score: 0
Accepted
time: 98ms
memory: 83900kb
input:
103124 99448
output:
695932649
result:
ok "695932649"
Test #24:
score: 0
Accepted
time: 83ms
memory: 83888kb
input:
109139 9937
output:
268916696
result:
ok "268916696"
Test #25:
score: 0
Accepted
time: 82ms
memory: 87964kb
input:
1031234 99238
output:
441457721
result:
ok "441457721"
Test #26:
score: 0
Accepted
time: 92ms
memory: 88024kb
input:
1091239 991237
output:
61047495
result:
ok "61047495"
Test #27:
score: 0
Accepted
time: 88ms
memory: 120824kb
input:
10000000 9982443
output:
224744113
result:
ok "224744113"
Test #28:
score: 0
Accepted
time: 120ms
memory: 120832kb
input:
9999977 5678901
output:
641748125
result:
ok "641748125"
Extra Test:
score: 0
Extra Test Passed