QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#22699 | #2142. Yurik and Woodwork Lesson | WhybullYMe# | AC ✓ | 5ms | 5408kb | C++20 | 2.3kb | 2022-03-10 15:30:01 | 2022-04-30 01:33:05 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ri int
typedef long long ll;
const int maxn=2e5+10,mod=998244353;
template<class T>inline bool ckmin(T &x,const T &y){return x>y?x=y,1:0;}
template<class T>inline bool ckmax(T &x,const T &y){return x<y?x=y,1:0;}
template<class T>inline void clear(T *arr,int siz,int val=0){memset(arr,val,sizeof(T)*(siz+1));}
struct modint{
int val;
inline modint(int val_=0):val(val_){}
inline modint &operator=(int val_){return val=val_,*this;}
inline modint &operator+=(const modint &k){return val=val+k.val>=mod?val+k.val-mod:val+k.val,*this;}
inline modint &operator-=(const modint &k){return val=val-k.val<0?val-k.val+mod:val-k.val,*this;}
inline modint &operator*=(const modint &k){return val=1ll*val*k.val%mod,*this;}
inline modint &operator^=(int k){
modint ret=1,tmp=*this;
for(;k;k>>=1,tmp*=tmp)if(k&1)ret*=tmp;
return val=ret.val,*this;
}
inline modint &operator/=(modint k){return *this*=(k^=mod-2);}
inline modint &operator+=(int k){return val=val+k>=mod?val+k-mod:val+k,*this;}
inline modint &operator-=(int k){return val=val<k?val-k+mod:val-k,*this;}
inline modint &operator*=(int k){return val=1ll*val*k%mod,*this;}
inline modint &operator/=(int k){return *this*=((modint(k))^=mod-2);}
template<class T>friend modint operator+(modint a,T b){return a+=b;}
template<class T>friend modint operator-(modint a,T b){return a-=b;}
template<class T>friend modint operator*(modint a,T b){return a*=b;}
template<class T>friend modint operator^(modint a,T b){return a/=b;}
template<class T>friend modint operator/(modint a,T b){return a/=b;}
friend modint operator^(modint a,int b){return a^=b;}
friend bool operator==(modint a,int b){return a.val==b;}
friend bool operator!=(modint a,int b){return a.val!=b;}
inline bool operator!(){return !val;}
inline modint operator-(){return val?mod-val:0;}
inline modint &operator++(){return *this+=1;}
};
using mi=modint;
mi fac[maxn],ifac[maxn];
inline void init(int sz){
fac[0]=1;
for(ri i=1;i<=sz;++i)fac[i]=fac[i-1]*i;
ifac[sz]=1/fac[sz];
for(ri i=sz;i;--i)ifac[i-1]=ifac[i]*i;
}
inline mi C(int x,int y){
if(x<y||y<0)return 0;
return fac[x]*ifac[y]*ifac[x-y];
}
int m,n;
int main(){
scanf("%d%d",&n,&m);
init(n+m-2);
printf("%d",C(n+m-2,n-1)*C(n+m-2,m-1)-C(n+m-2,n-2)*C(n+m-2,m-2));
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 5204kb
input:
2 2
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 4ms
memory: 5340kb
input:
2 4
output:
10
result:
ok 1 number(s): "10"
Test #3:
score: 0
Accepted
time: 2ms
memory: 5272kb
input:
100 100
output:
818380736
result:
ok 1 number(s): "818380736"
Test #4:
score: 0
Accepted
time: 1ms
memory: 5356kb
input:
1 1
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 5244kb
input:
1 2
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 4ms
memory: 5344kb
input:
1 3
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 0
Accepted
time: 3ms
memory: 5316kb
input:
1 4
output:
1
result:
ok 1 number(s): "1"
Test #8:
score: 0
Accepted
time: 3ms
memory: 5244kb
input:
1 5
output:
1
result:
ok 1 number(s): "1"
Test #9:
score: 0
Accepted
time: 4ms
memory: 5336kb
input:
2 1
output:
1
result:
ok 1 number(s): "1"
Test #10:
score: 0
Accepted
time: 4ms
memory: 5364kb
input:
2 2
output:
3
result:
ok 1 number(s): "3"
Test #11:
score: 0
Accepted
time: 1ms
memory: 5316kb
input:
2 3
output:
6
result:
ok 1 number(s): "6"
Test #12:
score: 0
Accepted
time: 1ms
memory: 5336kb
input:
2 4
output:
10
result:
ok 1 number(s): "10"
Test #13:
score: 0
Accepted
time: 3ms
memory: 5204kb
input:
2 5
output:
15
result:
ok 1 number(s): "15"
Test #14:
score: 0
Accepted
time: 3ms
memory: 5244kb
input:
3 1
output:
1
result:
ok 1 number(s): "1"
Test #15:
score: 0
Accepted
time: 3ms
memory: 5344kb
input:
3 2
output:
6
result:
ok 1 number(s): "6"
Test #16:
score: 0
Accepted
time: 2ms
memory: 5372kb
input:
3 3
output:
20
result:
ok 1 number(s): "20"
Test #17:
score: 0
Accepted
time: 1ms
memory: 5248kb
input:
3 4
output:
50
result:
ok 1 number(s): "50"
Test #18:
score: 0
Accepted
time: 3ms
memory: 5324kb
input:
3 5
output:
105
result:
ok 1 number(s): "105"
Test #19:
score: 0
Accepted
time: 0ms
memory: 5404kb
input:
4 1
output:
1
result:
ok 1 number(s): "1"
Test #20:
score: 0
Accepted
time: 3ms
memory: 5268kb
input:
4 2
output:
10
result:
ok 1 number(s): "10"
Test #21:
score: 0
Accepted
time: 0ms
memory: 5324kb
input:
4 3
output:
50
result:
ok 1 number(s): "50"
Test #22:
score: 0
Accepted
time: 3ms
memory: 5324kb
input:
4 4
output:
175
result:
ok 1 number(s): "175"
Test #23:
score: 0
Accepted
time: 4ms
memory: 5248kb
input:
4 5
output:
490
result:
ok 1 number(s): "490"
Test #24:
score: 0
Accepted
time: 2ms
memory: 5408kb
input:
5 1
output:
1
result:
ok 1 number(s): "1"
Test #25:
score: 0
Accepted
time: 0ms
memory: 5336kb
input:
5 2
output:
15
result:
ok 1 number(s): "15"
Test #26:
score: 0
Accepted
time: 4ms
memory: 5272kb
input:
5 3
output:
105
result:
ok 1 number(s): "105"
Test #27:
score: 0
Accepted
time: 0ms
memory: 5204kb
input:
5 4
output:
490
result:
ok 1 number(s): "490"
Test #28:
score: 0
Accepted
time: 0ms
memory: 5336kb
input:
5 5
output:
1764
result:
ok 1 number(s): "1764"
Test #29:
score: 0
Accepted
time: 2ms
memory: 5316kb
input:
1 9
output:
1
result:
ok 1 number(s): "1"
Test #30:
score: 0
Accepted
time: 2ms
memory: 5316kb
input:
8 4
output:
4950
result:
ok 1 number(s): "4950"
Test #31:
score: 0
Accepted
time: 1ms
memory: 5316kb
input:
2 48
output:
1176
result:
ok 1 number(s): "1176"
Test #32:
score: 0
Accepted
time: 1ms
memory: 5320kb
input:
57 4
output:
278114495
result:
ok 1 number(s): "278114495"
Test #33:
score: 0
Accepted
time: 1ms
memory: 5204kb
input:
82 51
output:
501711451
result:
ok 1 number(s): "501711451"
Test #34:
score: 0
Accepted
time: 1ms
memory: 5344kb
input:
4909 1
output:
1
result:
ok 1 number(s): "1"
Test #35:
score: 0
Accepted
time: 4ms
memory: 5344kb
input:
30 3890
output:
146479684
result:
ok 1 number(s): "146479684"
Test #36:
score: 0
Accepted
time: 2ms
memory: 5272kb
input:
2081 3619
output:
991511011
result:
ok 1 number(s): "991511011"
Test #37:
score: 0
Accepted
time: 4ms
memory: 5268kb
input:
9511 10
output:
282597455
result:
ok 1 number(s): "282597455"
Test #38:
score: 0
Accepted
time: 4ms
memory: 5352kb
input:
21 36014
output:
305749705
result:
ok 1 number(s): "305749705"
Test #39:
score: 0
Accepted
time: 4ms
memory: 5340kb
input:
10049 6765
output:
275321949
result:
ok 1 number(s): "275321949"
Test #40:
score: 0
Accepted
time: 4ms
memory: 5340kb
input:
13036 23902
output:
885509275
result:
ok 1 number(s): "885509275"
Test #41:
score: 0
Accepted
time: 2ms
memory: 5332kb
input:
1 100000
output:
1
result:
ok 1 number(s): "1"
Test #42:
score: 0
Accepted
time: 4ms
memory: 5336kb
input:
100000 1
output:
1
result:
ok 1 number(s): "1"
Test #43:
score: 0
Accepted
time: 5ms
memory: 5332kb
input:
98765 95678
output:
302812642
result:
ok 1 number(s): "302812642"
Test #44:
score: 0
Accepted
time: 2ms
memory: 5372kb
input:
100000 100000
output:
174524777
result:
ok 1 number(s): "174524777"