QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#22677#2142. Yurik and Woodwork LessonQyc_AK_NOI2022#AC ✓5ms8544kbC++117.6kb2022-03-10 15:16:382022-04-30 01:31:59

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 01:31:59]
  • 评测
  • 测评结果:AC
  • 用时:5ms
  • 内存:8544kb
  • [2022-03-10 15:16:38]
  • 提交

answer

#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<set>
#include<ctime>
#include<assert.h>
#define _INT_INF ((int)0x3f3f3f3f)
#define _UINT_MAX ((unsigned int)0xffffffff)
#define _INT_MAX ((int)0x7fffffff)
#define _LL_INF ((long long)0x3f3f3f3f3f3f3f3f)
#define _ULL_MAX ((unsigned long long)0xffffffffffffffff)
#define _LL_MAX ((long long)0x7fffffffffffffff)
#define reg register
namespace FastIO{
	#define inline __attribute__((always_inline)) inline
#ifdef LOCAL
	#define getChar getchar()
#else
	#define BUF_SIZE 33554432
	char __buff__[BUF_SIZE];char *__p1__=__buff__,*__p2__=__buff__;
	#define getChar (__p1__==__p2__&&(__p2__=(__p1__=__buff__)+fread(__buff__,1,BUF_SIZE,stdin),__p1__==__p2__)?EOF:*__p1__++)
#endif
	inline int read(){
		register int x=0;register char c=getChar;
		while(c<'0'||c>'9')	c=getChar;while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getChar;return x;
	}
	inline int reads(){
		register int x=0,y=1;register char c=getChar;
		while(c<'0'||c>'9') y&=(c!='-'),c=getChar;while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getChar;return y?x:-x;
	}
	inline long long readl(){
		register long long x=0;register char c=getChar;
		while(c<'0'||c>'9') c=getChar;while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getChar;return x;
	}
	inline int readsl(){
		register long long x=0;register int y=1;register char c=getChar;
		while(c<'0'||c>'9') y&=(c!='-'),c=getChar;while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getChar;return y?x:-x;
	}
	inline void read(char *s){
		register char c=getChar;while(c=='\n'||c=='\r'||c==' '||c=='\t') c=getChar;
        while(c!='\n'&&c!='\r'&&c!=' '&&c!='\t'&&c!=EOF) *s=c,s++,c=getChar;*s=0;
	}
	#undef getChar
	#define EN write('\n')
	#define SPACE write(' ')
#ifdef LOCAL
	#define RET 0
	inline void write(register int x){printf("%d",x);}
	inline void writeEN(register int x){printf("%d\n",x);}
	inline void writeSP(register int x){printf("%d ",x);}
	inline void write(register long long x){printf("%lld",x);}
	inline void writeEN(register long long x){printf("%lld\n",x);}
	inline void writeSP(register long long x){printf("%lld ",x);}
	inline void write(register char c){printf("%c",c);}
	inline void write(const char *c){printf("%s",c);}
#else
	#undef BUF_SIZE
	#define RET fwrite(__buffW__,1,__bb__,stdout),0
	#define BUFW_SIZE 33554432
	char __buffW__[BUFW_SIZE];int __bb__;
	char __stack__[28];
	inline void write(register int x,register short base=10){
		if(!x) return __buffW__[__bb__++]='0',void();if(x<0) __buffW__[__bb__++]='-',x=-x;
		register short top=0;
		while(x) __stack__[++top]=(x%base)^48,x/=base;while(top) __buffW__[__bb__++]=__stack__[top--];
	}
	inline void writeEN(register int x,register short base=10){
		if(!x) return __buffW__[__bb__++]='0',__buffW__[__bb__++]='\n',void();if(x<0) __buffW__[__bb__++]='-',x=-x;
		register short top=0;
		while(x) __stack__[++top]=(x%base)^48,x/=base;while(top) __buffW__[__bb__++]=__stack__[top--];__buffW__[__bb__++]='\n';
	}
	inline void writeSP(register int x,register short base=10){
		if(!x) return __buffW__[__bb__++]='0',__buffW__[__bb__++]=' ',void();if(x<0) __buffW__[__bb__++]='-',x=-x;
		register short top=0;
		while(x) __stack__[++top]=(x%base)^48,x/=base;while(top) __buffW__[__bb__++]=__stack__[top--];__buffW__[__bb__++]=' ';
	}
	inline void write(register long long x,register short base=10){
		if(!x) return __buffW__[__bb__++]='0',void();if(x<0) __buffW__[__bb__++]='-',x=-x;
		register short top=0;
		while(x) __stack__[++top]=(x%base)^48,x/=base;while(top) __buffW__[__bb__++]=__stack__[top--];
	}
	inline void writeEN(register long long x,register short base=10){
		if(!x) return __buffW__[__bb__++]='0',__buffW__[__bb__++]='\n',void();if(x<0) __buffW__[__bb__++]='-',x=-x;
		register short top=0;
		while(x) __stack__[++top]=(x%base)^48,x/=base;while(top) __buffW__[__bb__++]=__stack__[top--];__buffW__[__bb__++]='\n';
	}
	inline void writeSP(register long long x,register short base=10){
		if(!x) return __buffW__[__bb__++]='0',__buffW__[__bb__++]=' ',void();if(x<0) __buffW__[__bb__++]='-',x=-x;
		register short top=0;
		while(x) __stack__[++top]=(x%base)^48,x/=base;while(top) __buffW__[__bb__++]=__stack__[top--];__buffW__[__bb__++]=' ';
	}
	inline void write(register char c){__buffW__[__bb__++]=c;}
	inline void write(const char *c){while(*c) __buffW__[__bb__++]=*c,c++;}
	#undef BUFW_SIZE
#endif
#undef inline
}//namespace FastIO
using namespace FastIO;
namespace lib{
#define inline __attribute__((always_inline)) inline
	inline void chkMin(int &a,const int &b){(a>b)&&(a=b);}
	inline void chkMin(long long &a,const long long &b){(a>b)&&(a=b);}
	inline void chkMax(int &a,const int &b){(a<b)&&(a=b);}
	inline void chkMax(long long &a,const long long &b){(a<b)&&(a=b);}
	inline int min(const int &a,const int &b){return a>b?b:a;}
	inline long long min(const long long &a,const long long &b){return a>b?b:a;}
	inline int max(const int &a,const int &b){return a>b?a:b;}
	inline long long max(const long long &a,const long long &b){return a>b?a:b;}
	inline void swap(int &a,int &b){a^=b;b^=a;a^=b;}
	inline void swap(long long &a,long long &b){a^=b;b^=a;a^=b;}
	inline int abs(const int &a){return a>0?a:-a;}
	inline long long abs(const long long &a){return a>0?a:-a;}
#undef inline
}
#define N 400006
#define MOD 998244353
inline long long power(long long a,long long b,long long mod=MOD){
	long long ans=1;
	while(b){if(b&1) ans=ans*a%mod;a=a*a%mod;b>>=1;}
	return ans;
}
struct ModInt{
	long long x;
#define inline __attribute__((always_inline))
	inline ModInt operator - (){return {x?(MOD-x):0};}
	inline ModInt operator - (ModInt o){return {(x-o.x<0)?(x-o.x+MOD):(x-o.x)};}
	inline ModInt operator - (int o){return {(x-o<0)?(x-o+MOD):(x-o)};}
	inline void operator -= (ModInt o){x=(x-o.x<0)?(x-o.x+MOD):(x-o.x);}
	inline void operator -= (int o){x=(x-o<0)?(x-o+MOD):(x-o);}
	inline friend ModInt operator - (int a,ModInt b){return {(a-b.x<0)?(a-b.x+MOD):(a-b.x)};}
	inline void operator -- (int){x--;if(x<0) x=MOD-1;}
	inline ModInt operator + (ModInt o){return {(x+o.x>=MOD)?(x+o.x-MOD):(x+o.x)};}
	inline ModInt operator + (int o){return {(x+o>=MOD)?(x+o-MOD):(x+o)};}
	inline void operator += (ModInt o){x=(x+o.x>=MOD)?(x+o.x-MOD):(x+o.x);}
	inline void operator += (int o){x=(x+o>=MOD)?(x+o-MOD):(x+o);}
	inline friend ModInt operator + (int a,ModInt b){return {(b.x+a>=MOD)?(b.x+a-MOD):(b.x+a)};}
	inline void operator ++ (int){x++;if(x==MOD) x=0;}
	inline ModInt operator * (ModInt o){return {x*o.x%MOD};}
	inline ModInt operator * (int o){return {x*o%MOD};}
	inline void operator *= (ModInt o){x=x*o.x%MOD;}
	inline void operator *= (int o){x=x*o%MOD;}
	inline friend ModInt operator * (int a,ModInt b){return {a*b.x%MOD};}
	inline ModInt operator / (ModInt o){return {x*power(o.x,MOD-2)%MOD};}
	inline ModInt operator / (int o){return {x*power(o,MOD-2)%MOD};}
	inline void operator /= (ModInt o){x=x*power(o.x,MOD-2)%MOD;}
	inline void operator /= (int o){x=x*power(o,MOD-2)%MOD;}
	inline friend ModInt operator / (int a,ModInt b){return {a*power(b.x,MOD-2)%MOD};}
	inline void operator = (int a){x=a;}
	inline int operator == (const ModInt &o){return x==o.x;}
	inline int operator == (const int &o){return x==o;}
#undef inline
};
ModInt fac[N];
inline ModInt C(int n,int m){return fac[n]/fac[m]/fac[n-m];}
int main(){
	int n=read(),m=read();
	if(n>m) lib::swap(m,n);
	fac[0]=1;
	for(int i=1;i<=(n+m)*2;i++) fac[i]=fac[i-1]*i;
	ModInt ans;ans=C(n+m-1,n)*C(n+m-1,n);
	ans-=C(n+m,n)*C(n+m-2,n);

//	long long ans=C(n*2,n)*C(n*2,n);
//	ans-=C(n*2+1,n)*C(n*2-1,n);
	writeEN(ans.x);
	return RET;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5624kb

input:

2 2

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 2ms
memory: 5564kb

input:

2 4

output:

10

result:

ok 1 number(s): "10"

Test #3:

score: 0
Accepted
time: 1ms
memory: 5472kb

input:

100 100

output:

818380736

result:

ok 1 number(s): "818380736"

Test #4:

score: 0
Accepted
time: 1ms
memory: 5484kb

input:

1 1

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 3ms
memory: 5484kb

input:

1 2

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: 0
Accepted
time: 0ms
memory: 5588kb

input:

1 3

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: 0
Accepted
time: 0ms
memory: 5580kb

input:

1 4

output:

1

result:

ok 1 number(s): "1"

Test #8:

score: 0
Accepted
time: 1ms
memory: 5584kb

input:

1 5

output:

1

result:

ok 1 number(s): "1"

Test #9:

score: 0
Accepted
time: 2ms
memory: 5544kb

input:

2 1

output:

1

result:

ok 1 number(s): "1"

Test #10:

score: 0
Accepted
time: 0ms
memory: 5512kb

input:

2 2

output:

3

result:

ok 1 number(s): "3"

Test #11:

score: 0
Accepted
time: 2ms
memory: 5508kb

input:

2 3

output:

6

result:

ok 1 number(s): "6"

Test #12:

score: 0
Accepted
time: 2ms
memory: 5624kb

input:

2 4

output:

10

result:

ok 1 number(s): "10"

Test #13:

score: 0
Accepted
time: 2ms
memory: 5568kb

input:

2 5

output:

15

result:

ok 1 number(s): "15"

Test #14:

score: 0
Accepted
time: 2ms
memory: 5484kb

input:

3 1

output:

1

result:

ok 1 number(s): "1"

Test #15:

score: 0
Accepted
time: 0ms
memory: 5528kb

input:

3 2

output:

6

result:

ok 1 number(s): "6"

Test #16:

score: 0
Accepted
time: 1ms
memory: 5624kb

input:

3 3

output:

20

result:

ok 1 number(s): "20"

Test #17:

score: 0
Accepted
time: 2ms
memory: 5476kb

input:

3 4

output:

50

result:

ok 1 number(s): "50"

Test #18:

score: 0
Accepted
time: 2ms
memory: 5512kb

input:

3 5

output:

105

result:

ok 1 number(s): "105"

Test #19:

score: 0
Accepted
time: 2ms
memory: 5624kb

input:

4 1

output:

1

result:

ok 1 number(s): "1"

Test #20:

score: 0
Accepted
time: 1ms
memory: 5560kb

input:

4 2

output:

10

result:

ok 1 number(s): "10"

Test #21:

score: 0
Accepted
time: 2ms
memory: 5564kb

input:

4 3

output:

50

result:

ok 1 number(s): "50"

Test #22:

score: 0
Accepted
time: 2ms
memory: 5588kb

input:

4 4

output:

175

result:

ok 1 number(s): "175"

Test #23:

score: 0
Accepted
time: 0ms
memory: 5584kb

input:

4 5

output:

490

result:

ok 1 number(s): "490"

Test #24:

score: 0
Accepted
time: 2ms
memory: 5484kb

input:

5 1

output:

1

result:

ok 1 number(s): "1"

Test #25:

score: 0
Accepted
time: 1ms
memory: 5620kb

input:

5 2

output:

15

result:

ok 1 number(s): "15"

Test #26:

score: 0
Accepted
time: 2ms
memory: 5464kb

input:

5 3

output:

105

result:

ok 1 number(s): "105"

Test #27:

score: 0
Accepted
time: 1ms
memory: 5544kb

input:

5 4

output:

490

result:

ok 1 number(s): "490"

Test #28:

score: 0
Accepted
time: 0ms
memory: 5580kb

input:

5 5

output:

1764

result:

ok 1 number(s): "1764"

Test #29:

score: 0
Accepted
time: 1ms
memory: 5524kb

input:

1 9

output:

1

result:

ok 1 number(s): "1"

Test #30:

score: 0
Accepted
time: 0ms
memory: 5468kb

input:

8 4

output:

4950

result:

ok 1 number(s): "4950"

Test #31:

score: 0
Accepted
time: 0ms
memory: 5580kb

input:

2 48

output:

1176

result:

ok 1 number(s): "1176"

Test #32:

score: 0
Accepted
time: 1ms
memory: 5488kb

input:

57 4

output:

278114495

result:

ok 1 number(s): "278114495"

Test #33:

score: 0
Accepted
time: 2ms
memory: 5588kb

input:

82 51

output:

501711451

result:

ok 1 number(s): "501711451"

Test #34:

score: 0
Accepted
time: 0ms
memory: 5544kb

input:

4909 1

output:

1

result:

ok 1 number(s): "1"

Test #35:

score: 0
Accepted
time: 2ms
memory: 5680kb

input:

30 3890

output:

146479684

result:

ok 1 number(s): "146479684"

Test #36:

score: 0
Accepted
time: 2ms
memory: 5576kb

input:

2081 3619

output:

991511011

result:

ok 1 number(s): "991511011"

Test #37:

score: 0
Accepted
time: 1ms
memory: 5676kb

input:

9511 10

output:

282597455

result:

ok 1 number(s): "282597455"

Test #38:

score: 0
Accepted
time: 0ms
memory: 6088kb

input:

21 36014

output:

305749705

result:

ok 1 number(s): "305749705"

Test #39:

score: 0
Accepted
time: 2ms
memory: 5748kb

input:

10049 6765

output:

275321949

result:

ok 1 number(s): "275321949"

Test #40:

score: 0
Accepted
time: 1ms
memory: 6040kb

input:

13036 23902

output:

885509275

result:

ok 1 number(s): "885509275"

Test #41:

score: 0
Accepted
time: 1ms
memory: 7824kb

input:

1 100000

output:

1

result:

ok 1 number(s): "1"

Test #42:

score: 0
Accepted
time: 1ms
memory: 8192kb

input:

100000 1

output:

1

result:

ok 1 number(s): "1"

Test #43:

score: 0
Accepted
time: 5ms
memory: 7280kb

input:

98765 95678

output:

302812642

result:

ok 1 number(s): "302812642"

Test #44:

score: 0
Accepted
time: 5ms
memory: 8544kb

input:

100000 100000

output:

174524777

result:

ok 1 number(s): "174524777"