QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#140754 | #6736. Alice and Bob | 275307894a | AC ✓ | 127ms | 160184kb | C++14 | 970b | 2023-08-16 19:28:32 | 2023-08-16 19:28:35 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=1e7+5,M=2e3+5,K=63,mod=998244353,Mod=mod-1;const db eps=1e-9;const ll INF=1e18+7;mt19937 rnd(time(0));
int n,m;ll frc[N],inv[N];
int main(){
int i,j;scanf("%d",&n);
inv[1]=1;for(i=2;i<=n;i++) inv[i]=(mod-inv[mod%i])*(mod/i)%mod;
inv[0]=frc[0]=1;for(i=1;i<=n;i++) frc[i]=frc[i-1]*i%mod,inv[i]=inv[i-1]*inv[i]%mod;
ll ans=0;
auto C=[](int x,int y){return frc[x]*inv[y]%mod*inv[x-y]%mod;};
for(i=1;2*i-1<=n;i++) ans+=C(n-i,i-1)*frc[i-1]%mod*frc[n-i]%mod;
printf("%lld\n",ans%mod);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5780kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5856kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 5992kb
input:
10
output:
997920
result:
ok 1 number(s): "997920"
Test #4:
score: 0
Accepted
time: 1ms
memory: 5852kb
input:
100
output:
188898954
result:
ok 1 number(s): "188898954"
Test #5:
score: 0
Accepted
time: 0ms
memory: 6000kb
input:
4
output:
10
result:
ok 1 number(s): "10"
Test #6:
score: 0
Accepted
time: 1ms
memory: 5764kb
input:
8
output:
12336
result:
ok 1 number(s): "12336"
Test #7:
score: 0
Accepted
time: 1ms
memory: 5788kb
input:
16
output:
373118483
result:
ok 1 number(s): "373118483"
Test #8:
score: 0
Accepted
time: 1ms
memory: 6004kb
input:
32
output:
314585464
result:
ok 1 number(s): "314585464"
Test #9:
score: 0
Accepted
time: 1ms
memory: 5780kb
input:
64
output:
627827331
result:
ok 1 number(s): "627827331"
Test #10:
score: 0
Accepted
time: 1ms
memory: 5756kb
input:
128
output:
828497685
result:
ok 1 number(s): "828497685"
Test #11:
score: 0
Accepted
time: 1ms
memory: 5980kb
input:
256
output:
65697890
result:
ok 1 number(s): "65697890"
Test #12:
score: 0
Accepted
time: 1ms
memory: 5720kb
input:
512
output:
854187619
result:
ok 1 number(s): "854187619"
Test #13:
score: 0
Accepted
time: 1ms
memory: 6004kb
input:
1024
output:
513823539
result:
ok 1 number(s): "513823539"
Test #14:
score: 0
Accepted
time: 14ms
memory: 28552kb
input:
1361956
output:
617368199
result:
ok 1 number(s): "617368199"
Test #15:
score: 0
Accepted
time: 97ms
memory: 125220kb
input:
7579013
output:
827172636
result:
ok 1 number(s): "827172636"
Test #16:
score: 0
Accepted
time: 105ms
memory: 132924kb
input:
8145517
output:
710624331
result:
ok 1 number(s): "710624331"
Test #17:
score: 0
Accepted
time: 70ms
memory: 101260kb
input:
6140463
output:
707600568
result:
ok 1 number(s): "707600568"
Test #18:
score: 0
Accepted
time: 34ms
memory: 63916kb
input:
3515281
output:
698302413
result:
ok 1 number(s): "698302413"
Test #19:
score: 0
Accepted
time: 82ms
memory: 117460kb
input:
6969586
output:
69470392
result:
ok 1 number(s): "69470392"
Test #20:
score: 0
Accepted
time: 36ms
memory: 52016kb
input:
2888636
output:
433579983
result:
ok 1 number(s): "433579983"
Test #21:
score: 0
Accepted
time: 126ms
memory: 160184kb
input:
9999998
output:
758172780
result:
ok 1 number(s): "758172780"
Test #22:
score: 0
Accepted
time: 127ms
memory: 159972kb
input:
9999999
output:
605195495
result:
ok 1 number(s): "605195495"
Test #23:
score: 0
Accepted
time: 127ms
memory: 159968kb
input:
10000000
output:
866813682
result:
ok 1 number(s): "866813682"