QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#203804 | #6736. Alice and Bob | zzzyzzz# | AC ✓ | 723ms | 43032kb | C++17 | 1.8kb | 2023-10-06 20:38:10 | 2023-10-06 20:38:10 |
Judging History
answer
#include<bits/stdc++.h>
#include<sstream>
#include<cassert>
#define fi first
#define se second
#define i128 __int128
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> PII;
const double eps=1e-7;
const int N=5e5+7 ,M=5e5+7, INF=0x3f3f3f3f,mod=1e9+7,mod1=998244353;
const long long int llINF=0x3f3f3f3f3f3f3f3f;
inline ll read() {ll x=0,f=1;char c=getchar();while(c<'0'||c>'9') {if(c=='-') f=-1;c=getchar();}
while(c>='0'&&c<='9') {x=(ll)x*10+c-'0';c=getchar();} return x*f;}
inline void write(ll x) {if(x < 0) {putchar('-'); x = -x;}if(x >= 10) write(x / 10);putchar(x % 10 + '0');}
inline void write(ll x,char ch) {write(x);putchar(ch);}
void stin() {freopen("in_put.txt","r",stdin);freopen("my_out_put.txt","w",stdout);}
bool cmp0(int a,int b) {return a>b;}
template<typename T> T gcd(T a,T b) {return b==0?a:gcd(b,a%b);}
template<typename T> T lcm(T a,T b) {return a*b/gcd(a,b);}
void hack() {printf("\n----------------------------------\n");}
const int F=1e7+7;
int T,hackT;
int n,m,k;
struct Cab{
int A[F];
void init() {
A[0]=1;
for(int i=1;i<=10000000;i++) A[i]=(ll)A[i-1]*i%mod1;
}
int qmi(int a,int b,int mod) {
int res=1%mod;
while(b) {
if(b&1) res=(ll)res*a%mod1;
a=(ll)a*a%mod1;
b=b>>1;
}
return res;
}
int C(int a,int b) {
if(a<b) return 0;
int res=(ll)A[b]*A[a-b]%mod1;
return ((ll)A[a]*qmi(res,mod1-2,mod1))%mod1;
}
};
Cab C;
void solve() {
n=read();
C.init();
int res=0;
for(int i=1;i<=n;i++) {
int temp=(ll)C.A[i-1]*C.A[n-i]%mod1;
res=(res+(ll)C.C(n-i,i-1)*temp%mod1)%mod1;
}
printf("%d\n",res);
}
int main() {
// init();
// stin();
// ios::sync_with_stdio(false);
// scanf("%d",&T);
T=1;
while(T--) hackT++,solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 44ms
memory: 42848kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 39ms
memory: 42868kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 46ms
memory: 42844kb
input:
10
output:
997920
result:
ok 1 number(s): "997920"
Test #4:
score: 0
Accepted
time: 42ms
memory: 43032kb
input:
100
output:
188898954
result:
ok 1 number(s): "188898954"
Test #5:
score: 0
Accepted
time: 39ms
memory: 43028kb
input:
4
output:
10
result:
ok 1 number(s): "10"
Test #6:
score: 0
Accepted
time: 47ms
memory: 42848kb
input:
8
output:
12336
result:
ok 1 number(s): "12336"
Test #7:
score: 0
Accepted
time: 43ms
memory: 42920kb
input:
16
output:
373118483
result:
ok 1 number(s): "373118483"
Test #8:
score: 0
Accepted
time: 43ms
memory: 42848kb
input:
32
output:
314585464
result:
ok 1 number(s): "314585464"
Test #9:
score: 0
Accepted
time: 43ms
memory: 42840kb
input:
64
output:
627827331
result:
ok 1 number(s): "627827331"
Test #10:
score: 0
Accepted
time: 40ms
memory: 42852kb
input:
128
output:
828497685
result:
ok 1 number(s): "828497685"
Test #11:
score: 0
Accepted
time: 43ms
memory: 42904kb
input:
256
output:
65697890
result:
ok 1 number(s): "65697890"
Test #12:
score: 0
Accepted
time: 40ms
memory: 42968kb
input:
512
output:
854187619
result:
ok 1 number(s): "854187619"
Test #13:
score: 0
Accepted
time: 47ms
memory: 42840kb
input:
1024
output:
513823539
result:
ok 1 number(s): "513823539"
Test #14:
score: 0
Accepted
time: 135ms
memory: 42916kb
input:
1361956
output:
617368199
result:
ok 1 number(s): "617368199"
Test #15:
score: 0
Accepted
time: 555ms
memory: 42844kb
input:
7579013
output:
827172636
result:
ok 1 number(s): "827172636"
Test #16:
score: 0
Accepted
time: 589ms
memory: 42844kb
input:
8145517
output:
710624331
result:
ok 1 number(s): "710624331"
Test #17:
score: 0
Accepted
time: 454ms
memory: 42828kb
input:
6140463
output:
707600568
result:
ok 1 number(s): "707600568"
Test #18:
score: 0
Accepted
time: 283ms
memory: 42904kb
input:
3515281
output:
698302413
result:
ok 1 number(s): "698302413"
Test #19:
score: 0
Accepted
time: 509ms
memory: 42924kb
input:
6969586
output:
69470392
result:
ok 1 number(s): "69470392"
Test #20:
score: 0
Accepted
time: 234ms
memory: 42852kb
input:
2888636
output:
433579983
result:
ok 1 number(s): "433579983"
Test #21:
score: 0
Accepted
time: 714ms
memory: 42844kb
input:
9999998
output:
758172780
result:
ok 1 number(s): "758172780"
Test #22:
score: 0
Accepted
time: 723ms
memory: 42908kb
input:
9999999
output:
605195495
result:
ok 1 number(s): "605195495"
Test #23:
score: 0
Accepted
time: 718ms
memory: 42972kb
input:
10000000
output:
866813682
result:
ok 1 number(s): "866813682"