QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#22646#2142. Yurik and Woodwork Lessonhy_zheng_zai_nei_juan#AC ✓6ms10488kbC++201.8kb2022-03-10 14:46:392022-04-30 01:29:16

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:29:16]
  • 评测
  • 测评结果:AC
  • 用时:6ms
  • 内存:10488kb
  • [2022-03-10 14:46:39]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<sstream>
#include<cctype>
#include<cmath>
#include<iomanip>
#include<map>
#include<stack>
#include<set>
#include<functional>
#define in(x) x=read()
#define qr read()
#define int ll
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
namespace fastIO
{
    #define BUF_SIZE 100000
    bool IOerror=0;
    inline char nc()
	{
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if (p1==pend){
            p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if (pend==p1){IOerror=1;return -1;}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline ll read()
	{
        bool sign=0; char ch=nc();ll x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return 0;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
        return x;
    }
    #undef BUF_SIZE
};
using namespace fastIO;
#define mod 998244353
int fac[1000010],ifac[1000010];
int qpow(int n,int k)
{
	int ans=1;
	while(k)
	{
		if(k&1)ans*=n,ans%=mod;
		n*=n,n%=mod;
		k>>=1;
	}
	return ans;
}
int C(int x,int y){return fac[x]*ifac[y]%mod*ifac[x-y]%mod;}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n=qr,m=qr;
	fac[0]=1;
	for(int i=1;i<=n+m;i++)fac[i]=fac[i-1]*i%mod;
	ifac[n+m]=qpow(fac[n+m],mod-2);
	for(int i=n+m-1;i>=0;i--)ifac[i]=ifac[i+1]*(i+1)%mod;
	cout<<(C(n+m-2,n-1)*C(n+m-2,n-1)%mod+mod-C(n+m-2,n)*C(n+m-2,m)%mod)%mod;
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 5700kb

input:

2 2

output:

3

result:

ok 1 number(s): "3"

Test #2:

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

input:

2 4

output:

10

result:

ok 1 number(s): "10"

Test #3:

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

input:

100 100

output:

818380736

result:

ok 1 number(s): "818380736"

Test #4:

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

input:

1 1

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

1 2

output:

1

result:

ok 1 number(s): "1"

Test #6:

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

input:

1 3

output:

1

result:

ok 1 number(s): "1"

Test #7:

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

input:

1 4

output:

1

result:

ok 1 number(s): "1"

Test #8:

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

input:

1 5

output:

1

result:

ok 1 number(s): "1"

Test #9:

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

input:

2 1

output:

1

result:

ok 1 number(s): "1"

Test #10:

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

input:

2 2

output:

3

result:

ok 1 number(s): "3"

Test #11:

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

input:

2 3

output:

6

result:

ok 1 number(s): "6"

Test #12:

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

input:

2 4

output:

10

result:

ok 1 number(s): "10"

Test #13:

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

input:

2 5

output:

15

result:

ok 1 number(s): "15"

Test #14:

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

input:

3 1

output:

1

result:

ok 1 number(s): "1"

Test #15:

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

input:

3 2

output:

6

result:

ok 1 number(s): "6"

Test #16:

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

input:

3 3

output:

20

result:

ok 1 number(s): "20"

Test #17:

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

input:

3 4

output:

50

result:

ok 1 number(s): "50"

Test #18:

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

input:

3 5

output:

105

result:

ok 1 number(s): "105"

Test #19:

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

input:

4 1

output:

1

result:

ok 1 number(s): "1"

Test #20:

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

input:

4 2

output:

10

result:

ok 1 number(s): "10"

Test #21:

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

input:

4 3

output:

50

result:

ok 1 number(s): "50"

Test #22:

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

input:

4 4

output:

175

result:

ok 1 number(s): "175"

Test #23:

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

input:

4 5

output:

490

result:

ok 1 number(s): "490"

Test #24:

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

input:

5 1

output:

1

result:

ok 1 number(s): "1"

Test #25:

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

input:

5 2

output:

15

result:

ok 1 number(s): "15"

Test #26:

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

input:

5 3

output:

105

result:

ok 1 number(s): "105"

Test #27:

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

input:

5 4

output:

490

result:

ok 1 number(s): "490"

Test #28:

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

input:

5 5

output:

1764

result:

ok 1 number(s): "1764"

Test #29:

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

input:

1 9

output:

1

result:

ok 1 number(s): "1"

Test #30:

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

input:

8 4

output:

4950

result:

ok 1 number(s): "4950"

Test #31:

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

input:

2 48

output:

1176

result:

ok 1 number(s): "1176"

Test #32:

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

input:

57 4

output:

278114495

result:

ok 1 number(s): "278114495"

Test #33:

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

input:

82 51

output:

501711451

result:

ok 1 number(s): "501711451"

Test #34:

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

input:

4909 1

output:

1

result:

ok 1 number(s): "1"

Test #35:

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

input:

30 3890

output:

146479684

result:

ok 1 number(s): "146479684"

Test #36:

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

input:

2081 3619

output:

991511011

result:

ok 1 number(s): "991511011"

Test #37:

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

input:

9511 10

output:

282597455

result:

ok 1 number(s): "282597455"

Test #38:

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

input:

21 36014

output:

305749705

result:

ok 1 number(s): "305749705"

Test #39:

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

input:

10049 6765

output:

275321949

result:

ok 1 number(s): "275321949"

Test #40:

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

input:

13036 23902

output:

885509275

result:

ok 1 number(s): "885509275"

Test #41:

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

input:

1 100000

output:

1

result:

ok 1 number(s): "1"

Test #42:

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

input:

100000 1

output:

1

result:

ok 1 number(s): "1"

Test #43:

score: 0
Accepted
time: 6ms
memory: 10488kb

input:

98765 95678

output:

302812642

result:

ok 1 number(s): "302812642"

Test #44:

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

input:

100000 100000

output:

174524777

result:

ok 1 number(s): "174524777"