QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#762597 | #8023. The Journey of Geor Autumn | TianShuiXingHe | AC ✓ | 185ms | 238356kb | C++17 | 2.1kb | 2024-11-19 15:42:39 | 2024-11-19 15:42:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
namespace basic{
#define int long long
#define uint unsigned int
#define per(i,a,b) for(int i=(a);i<=(b);i++)
#define perr(i,a,b,c) for(int i=(a);i<=(b);i+=(c))
#define rep(i,b,a) for(int i=(b);i>=(a);i--)
#define epb emplace_back
#define bit(x) (1ll<<(x))
#define all(x,l,r) &(x)[l],&(x)[r]+1
#define vall(x) (x).begin(),(x).end()
#define lowbit(x) ((x)&(-(x)))
#define pc(x) putchar(x)
#define turn(x) (x-'a'+1)
#define cto const auto
template <class T> bool chkmn(T &x,T y){return x>y?(x=y,1):0;}
template <class T> bool chkmn(T &x,T y,T z){return y<z?(x=y,1):(x=z,0);}
template <class T> bool chkmx(T &x,T y){return x<y?(x=y,1):0;}
template <class T> bool chkmx(T &x,T y,T z){return y>z?(x=y,1):(x=z,0);}
char *p1,*p2,buf[100000];
#define nc() (p1==p2 && (p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
int read(){
int x=0,f=1;char ch=nc();
while(ch<48||ch>57){if(ch=='-') f=-1;ch=nc();}
while(ch>=48&&ch<=57) x=x*10+ch-48,ch=nc();
return x*f;
}
void write(int x){
if(x<0) pc('-'),x=-x;
if(x>9) write(x/10);
pc(x%10+'0');
}
void print(string s,char op=0){for(auto x:s) pc(x);op&&pc(op);}
void print(int x,char op=0){write(x);op&&pc(op);}
}
using namespace basic;
namespace fisher{
bool mbe;void cntime();
const int N=1e7+5,mod=998244353;
int n,k,f[N];
int fac[N],inv[N];
int gmod(int x){
return x<-mod?x%mod+mod:(x<0?x+mod:(x<mod?x:(x<(mod<<1)?x-mod:x%mod)));
}
int qpow(int a,int b){
int res=1;
for(;b;b>>=1,a=gmod(a*a))
if(b&1) res=gmod(res*a);
return res;
}
int A(int n,int m){
if(n<m) return 0;
return gmod(fac[n]*inv[n-m]);
}
void main(){
n=read();k=read();
fac[0]=inv[0]=1;
per(i,1,n) fac[i]=gmod(fac[i-1]*i);
inv[n]=qpow(fac[n],mod-2);
rep(i,n-1,1) inv[i]=gmod(inv[i+1]*(i+1));
per(i,0,k) f[i]=fac[i];
per(i,k+1,n)
f[i]=gmod(gmod(f[i-1]*i)-gmod(A(i-2,k-1)*gmod(f[i-k-1]*(i-1))));
print(f[n],'\n');
return cntime();
}
bool mbd;void cntime(){
cerr<<"Memory: "<<abs(&mbd-&mbe)/1048476.0<<" MB\n";
cerr<<"Time: "<<1e3*clock()/CLOCKS_PER_SEC<<" ms\n";
}}
signed main(){
fisher::main();
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7988kb
input:
1 1
output:
1
result:
ok "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 7924kb
input:
1 2
output:
1
result:
ok "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 8060kb
input:
1 3
output:
1
result:
ok "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 9908kb
input:
1 4
output:
1
result:
ok "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 8012kb
input:
2 1
output:
1
result:
ok "1"
Test #6:
score: 0
Accepted
time: 1ms
memory: 7988kb
input:
2 2
output:
2
result:
ok "2"
Test #7:
score: 0
Accepted
time: 1ms
memory: 8076kb
input:
2 3
output:
2
result:
ok "2"
Test #8:
score: 0
Accepted
time: 0ms
memory: 8012kb
input:
2 4
output:
2
result:
ok "2"
Test #9:
score: 0
Accepted
time: 1ms
memory: 8044kb
input:
3 1
output:
1
result:
ok "1"
Test #10:
score: 0
Accepted
time: 0ms
memory: 8060kb
input:
3 2
output:
4
result:
ok "4"
Test #11:
score: 0
Accepted
time: 0ms
memory: 8056kb
input:
3 3
output:
6
result:
ok "6"
Test #12:
score: 0
Accepted
time: 0ms
memory: 8056kb
input:
3 4
output:
6
result:
ok "6"
Test #13:
score: 0
Accepted
time: 0ms
memory: 8056kb
input:
4 1
output:
1
result:
ok "1"
Test #14:
score: 0
Accepted
time: 0ms
memory: 7988kb
input:
4 2
output:
10
result:
ok "10"
Test #15:
score: 0
Accepted
time: 1ms
memory: 8056kb
input:
4 3
output:
18
result:
ok "18"
Test #16:
score: 0
Accepted
time: 1ms
memory: 8108kb
input:
4 4
output:
24
result:
ok "24"
Test #17:
score: 0
Accepted
time: 0ms
memory: 8076kb
input:
99 50
output:
955866606
result:
ok "955866606"
Test #18:
score: 0
Accepted
time: 0ms
memory: 7928kb
input:
99 70
output:
296999003
result:
ok "296999003"
Test #19:
score: 0
Accepted
time: 1ms
memory: 8056kb
input:
1034 998
output:
637688669
result:
ok "637688669"
Test #20:
score: 0
Accepted
time: 1ms
memory: 8072kb
input:
1099 997
output:
712935289
result:
ok "712935289"
Test #21:
score: 0
Accepted
time: 1ms
memory: 8184kb
input:
10314 998
output:
224695890
result:
ok "224695890"
Test #22:
score: 0
Accepted
time: 0ms
memory: 8152kb
input:
10929 9974
output:
160291286
result:
ok "160291286"
Test #23:
score: 0
Accepted
time: 3ms
memory: 14804kb
input:
103124 99448
output:
695932649
result:
ok "695932649"
Test #24:
score: 0
Accepted
time: 2ms
memory: 14756kb
input:
109139 9937
output:
268916696
result:
ok "268916696"
Test #25:
score: 0
Accepted
time: 24ms
memory: 33056kb
input:
1031234 99238
output:
441457721
result:
ok "441457721"
Test #26:
score: 0
Accepted
time: 14ms
memory: 35336kb
input:
1091239 991237
output:
61047495
result:
ok "61047495"
Test #27:
score: 0
Accepted
time: 146ms
memory: 238348kb
input:
10000000 9982443
output:
224744113
result:
ok "224744113"
Test #28:
score: 0
Accepted
time: 185ms
memory: 238356kb
input:
9999977 5678901
output:
641748125
result:
ok "641748125"
Extra Test:
score: 0
Extra Test Passed