QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#507065 | #8635. 圆 | LGMaster | 10 | 64ms | 199368kb | C++14 | 1.2kb | 2024-08-06 09:49:23 | 2024-08-06 09:49:23 |
Judging History
answer
#include<bits/stdc++.h>
#define lint long long
using namespace std;
inline lint read(){
char c; lint f=1,res=0;
while(c=getchar(),!isdigit(c)) if(c=='-') f*=-1;
while(isdigit(c)) res=res*10+c-'0',c=getchar();
return res*f;
}
void write(int x){
if(x<0){
putchar('-');
x=-x;
}
static int sta[35];
int top=0;
do{
sta[top++]=x%10,x/=10;
}while(x);
while(top)putchar(sta[--top]+'0');
}
const int N=5005,mod=998244353;
lint n,f[N][N],fac[N],ans;
inline lint ksm(lint a,lint b){
lint res=1;
while(b){
if(b&1) res=(res*a)%mod;
a=(a*a)%mod;
b>>=1;
}
return res;
}
inline bool check(){
return n<=3;
}
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
n=read();
if(check()) puts("1"),exit(0);
f[1][1]=fac[1]=1;
for(int i=2;i<=n;i++){
fac[i]=(fac[i-1]*i)%mod;
for(int j=1;j<=n;j++){
f[i][j]=(f[i-1][j-1]+f[i-2][j-1])%mod;
if(i>=4) f[i][j]=(f[i][j]+f[i-3][j-1])%mod;
}
}
for(int i=1;i<=n;i++) ans=(ans+((f[n-3][i-1]*2+f[n-4][i-1]+f[n-2][i])%mod)*i%mod*fac[i-1]%mod*fac[n-i]%mod)%mod;
int inv=ksm(fac[n-1],mod-2);
printf("%lld",1);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 0ms
memory: 3684kb
input:
3
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Wrong Answer
time: 1ms
memory: 5900kb
input:
4
output:
1
result:
wrong answer 1st numbers differ - expected: '2', found: '1'
Test #3:
score: 0
Wrong Answer
time: 0ms
memory: 3812kb
input:
6
output:
1
result:
wrong answer 1st numbers differ - expected: '299473309', found: '1'
Test #4:
score: 0
Wrong Answer
time: 0ms
memory: 3892kb
input:
10
output:
1
result:
wrong answer 1st numbers differ - expected: '487238321', found: '1'
Test #5:
score: 0
Wrong Answer
time: 0ms
memory: 8164kb
input:
100
output:
1
result:
wrong answer 1st numbers differ - expected: '41620761', found: '1'
Test #6:
score: 0
Wrong Answer
time: 2ms
memory: 12080kb
input:
200
output:
1
result:
wrong answer 1st numbers differ - expected: '208771764', found: '1'
Test #7:
score: 0
Wrong Answer
time: 0ms
memory: 22688kb
input:
500
output:
1
result:
wrong answer 1st numbers differ - expected: '888621375', found: '1'
Test #8:
score: 0
Wrong Answer
time: 53ms
memory: 192980kb
input:
4798
output:
1
result:
wrong answer 1st numbers differ - expected: '319137015', found: '1'
Test #9:
score: 0
Wrong Answer
time: 55ms
memory: 199344kb
input:
4999
output:
1
result:
wrong answer 1st numbers differ - expected: '818467659', found: '1'
Test #10:
score: 0
Wrong Answer
time: 64ms
memory: 199368kb
input:
5000
output:
1
result:
wrong answer 1st numbers differ - expected: '142907477', found: '1'