QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#22701#2142. Yurik and Woodwork LessonMr_Eight#AC ✓20ms27156kbC++202.8kb2022-03-10 15:32:362022-04-30 01:33:13

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:33:13]
  • 评测
  • 测评结果:AC
  • 用时:20ms
  • 内存:27156kb
  • [2022-03-10 15:32:36]
  • 提交

answer

//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <climits>
#include <functional>
#include <cstring>
#include <string>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <complex>
//#include <random>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/priority_queue.hpp>
#define itn int
#define nit int
#define ll long long
#define ms multiset
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define re register
#define ri re int
#define il inline
#define pii pair<int,int>
#define cp complex<double>
#define vi vector<int>
#define ull unsigned long long
#define mem0(x) memset(x,0,sizeof(x))
#define mem0x3f(x) memset(x,0x3f,sizeof(x))
using namespace std;
//using namespace __gnu_pbds;
const double Pi=acos(-1);
namespace fastIO {
	template<class T>
	inline void read(T &x) {
		x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		if(fu)x=-x;
	}
	inline int read() {
		int x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		return fu?-x:x;
	}
	template<class T,class... Args>
	inline void read(T& t,Args&... args) {
		read(t);
		read(args...);
	}
	char _n_u_m_[40];
	template<class T>
	inline void write(T x) {
		if(x==0){
			putchar('0');
			return;
		}
		T tmp = x > 0 ? x : -x ;
		if( x < 0 ) putchar('-') ;
		register int cnt = 0 ;
		while( tmp > 0 ) {
			_n_u_m_[ cnt ++ ] = tmp % 10 + '0' ;
			tmp /= 10 ;
		}
		while( cnt > 0 ) putchar(_n_u_m_[ -- cnt ]) ;
	}
	template<class T>
	inline void write(T x ,char ch) {
		write(x);
		putchar(ch);
	}
}
using namespace fastIO;
#define mod 998244353
int n,m;
ll fac[1000002],ifac[1000002],inv[1000002];
inline long long pw(long long x,long long p){
    long long res=1;
    for(;p;p>>=1,x=x*x%mod)
        if(p&1)res=res*x%mod;
    return res;
}
inline long long getm(long long top,long long bot) {
	return (top*pw(bot,mod-2))%mod;
}
inline long long C(long long top,long long bot){
	if(top<bot||top<0||bot<0)return 0;
	return fac[top]*ifac[bot]%mod*ifac[top-bot]%mod;
}
int main() {
	n=1000000;
	fac[0]=1;
	F(i,1,n)fac[i]=fac[i-1]*i%mod;
	ifac[n]=getm(1,fac[n]);
	UF(i,n-1,0)ifac[i]=ifac[i+1]*(i+1)%mod;
	F(i,1,n)inv[i]=ifac[i]*fac[i-1]%mod;
	cin>>n>>m;
	if(n==1||m==1){
		cout<<1;
		return 0;
	}
	ll ans=C(m+n-2,n-1)*C(m+n-2,n-1)-C(m+n-2,n-2)*C(m+n-2,n);
	cout<<(ans%mod+mod)%mod;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 27020kb

input:

2 2

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 4ms
memory: 27116kb

input:

2 4

output:

10

result:

ok 1 number(s): "10"

Test #3:

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

input:

100 100

output:

818380736

result:

ok 1 number(s): "818380736"

Test #4:

score: 0
Accepted
time: 15ms
memory: 27084kb

input:

1 1

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 14ms
memory: 27156kb

input:

1 2

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: 0
Accepted
time: 11ms
memory: 26976kb

input:

1 3

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: 0
Accepted
time: 7ms
memory: 27084kb

input:

1 4

output:

1

result:

ok 1 number(s): "1"

Test #8:

score: 0
Accepted
time: 9ms
memory: 27104kb

input:

1 5

output:

1

result:

ok 1 number(s): "1"

Test #9:

score: 0
Accepted
time: 14ms
memory: 26884kb

input:

2 1

output:

1

result:

ok 1 number(s): "1"

Test #10:

score: 0
Accepted
time: 11ms
memory: 26996kb

input:

2 2

output:

3

result:

ok 1 number(s): "3"

Test #11:

score: 0
Accepted
time: 9ms
memory: 27084kb

input:

2 3

output:

6

result:

ok 1 number(s): "6"

Test #12:

score: 0
Accepted
time: 14ms
memory: 27004kb

input:

2 4

output:

10

result:

ok 1 number(s): "10"

Test #13:

score: 0
Accepted
time: 18ms
memory: 27004kb

input:

2 5

output:

15

result:

ok 1 number(s): "15"

Test #14:

score: 0
Accepted
time: 7ms
memory: 27000kb

input:

3 1

output:

1

result:

ok 1 number(s): "1"

Test #15:

score: 0
Accepted
time: 16ms
memory: 27032kb

input:

3 2

output:

6

result:

ok 1 number(s): "6"

Test #16:

score: 0
Accepted
time: 8ms
memory: 27004kb

input:

3 3

output:

20

result:

ok 1 number(s): "20"

Test #17:

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

input:

3 4

output:

50

result:

ok 1 number(s): "50"

Test #18:

score: 0
Accepted
time: 11ms
memory: 26972kb

input:

3 5

output:

105

result:

ok 1 number(s): "105"

Test #19:

score: 0
Accepted
time: 15ms
memory: 27104kb

input:

4 1

output:

1

result:

ok 1 number(s): "1"

Test #20:

score: 0
Accepted
time: 9ms
memory: 27036kb

input:

4 2

output:

10

result:

ok 1 number(s): "10"

Test #21:

score: 0
Accepted
time: 11ms
memory: 26884kb

input:

4 3

output:

50

result:

ok 1 number(s): "50"

Test #22:

score: 0
Accepted
time: 11ms
memory: 27016kb

input:

4 4

output:

175

result:

ok 1 number(s): "175"

Test #23:

score: 0
Accepted
time: 9ms
memory: 27028kb

input:

4 5

output:

490

result:

ok 1 number(s): "490"

Test #24:

score: 0
Accepted
time: 17ms
memory: 27080kb

input:

5 1

output:

1

result:

ok 1 number(s): "1"

Test #25:

score: 0
Accepted
time: 4ms
memory: 27156kb

input:

5 2

output:

15

result:

ok 1 number(s): "15"

Test #26:

score: 0
Accepted
time: 20ms
memory: 26952kb

input:

5 3

output:

105

result:

ok 1 number(s): "105"

Test #27:

score: 0
Accepted
time: 16ms
memory: 27020kb

input:

5 4

output:

490

result:

ok 1 number(s): "490"

Test #28:

score: 0
Accepted
time: 9ms
memory: 27032kb

input:

5 5

output:

1764

result:

ok 1 number(s): "1764"

Test #29:

score: 0
Accepted
time: 10ms
memory: 27092kb

input:

1 9

output:

1

result:

ok 1 number(s): "1"

Test #30:

score: 0
Accepted
time: 14ms
memory: 27080kb

input:

8 4

output:

4950

result:

ok 1 number(s): "4950"

Test #31:

score: 0
Accepted
time: 14ms
memory: 27000kb

input:

2 48

output:

1176

result:

ok 1 number(s): "1176"

Test #32:

score: 0
Accepted
time: 9ms
memory: 27088kb

input:

57 4

output:

278114495

result:

ok 1 number(s): "278114495"

Test #33:

score: 0
Accepted
time: 7ms
memory: 27020kb

input:

82 51

output:

501711451

result:

ok 1 number(s): "501711451"

Test #34:

score: 0
Accepted
time: 19ms
memory: 27032kb

input:

4909 1

output:

1

result:

ok 1 number(s): "1"

Test #35:

score: 0
Accepted
time: 11ms
memory: 27156kb

input:

30 3890

output:

146479684

result:

ok 1 number(s): "146479684"

Test #36:

score: 0
Accepted
time: 14ms
memory: 27004kb

input:

2081 3619

output:

991511011

result:

ok 1 number(s): "991511011"

Test #37:

score: 0
Accepted
time: 14ms
memory: 27116kb

input:

9511 10

output:

282597455

result:

ok 1 number(s): "282597455"

Test #38:

score: 0
Accepted
time: 9ms
memory: 27008kb

input:

21 36014

output:

305749705

result:

ok 1 number(s): "305749705"

Test #39:

score: 0
Accepted
time: 19ms
memory: 26956kb

input:

10049 6765

output:

275321949

result:

ok 1 number(s): "275321949"

Test #40:

score: 0
Accepted
time: 18ms
memory: 27024kb

input:

13036 23902

output:

885509275

result:

ok 1 number(s): "885509275"

Test #41:

score: 0
Accepted
time: 11ms
memory: 27020kb

input:

1 100000

output:

1

result:

ok 1 number(s): "1"

Test #42:

score: 0
Accepted
time: 4ms
memory: 27020kb

input:

100000 1

output:

1

result:

ok 1 number(s): "1"

Test #43:

score: 0
Accepted
time: 9ms
memory: 26888kb

input:

98765 95678

output:

302812642

result:

ok 1 number(s): "302812642"

Test #44:

score: 0
Accepted
time: 12ms
memory: 27008kb

input:

100000 100000

output:

174524777

result:

ok 1 number(s): "174524777"