QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#22651 | #2142. Yurik and Woodwork Lesson | ha114514ha# | AC ✓ | 6ms | 8708kb | C++20 | 3.4kb | 2022-03-10 14:52:59 | 2022-04-30 01:29:36 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<queue>
#include<vector>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
#include<ctime>
#include<random>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define bc(x) __builtin_popcount(x)
#define re register
#define il inline
#define pii pair<int,int>
#define pil pair<int,long long>
#define pll pair<long long,long long>
#define mem0(x) memset(x,0,sizeof(x))
#define mem0x3f(x) memset(x,0x3f,sizeof(x))
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n';
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n';
// #pragma GCC optimize(3)
#define int long long
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
namespace IO_BUFF{
mt19937 rnd(time(0)^(ll)(new char));
int rend(int x){
return rnd()%x+1;
}
void rendom_shuffle(int *a,int len){
shuffle(a+1,a+len+1,rnd);
}
const int BS=(1<<24)+5;char Buffer[BS],*HD,*TL;
inline int gc(){
if(HD==TL) TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);
return (HD==TL)?EOF:*HD++;
}
inline int inn(){
int x,ch,s=1;while((ch=gc())<'0'||ch>'9')if(ch=='-')s=-1;x=ch^'0';
while((ch=gc())>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^'0');return x*s;
}
char ssss[19999999],tttt[20];int ssl,ttl;
inline int print(int x)
{
if(x<0)ssss[++ssl]='-',x=(-x);
if(!x) ssss[++ssl]='0';for(ttl=0;x;x/=10) tttt[++ttl]=char(x%10+'0');
for(;ttl;ttl--) ssss[++ssl]=tttt[ttl];return ssss[++ssl]='\n';
}
inline int Flush(){return fwrite(ssss+1,sizeof(char),ssl,stdout),ssl=0,0;}
int read(){
char c=getchar();int x=1;int s=0;
while(c<'0' || c>'9'){if(c=='-')x=-1;c=getchar();}
while(c>='0' && c<='9'){
s=s*10+c-'0';c=getchar();
}
return s*x;
}
}using namespace IO_BUFF;
namespace CFConTest{
const int mod=998244353;
inline int add(const int &x,const int &y){
return (x+y>=mod?x+y-mod:x+y);
}
inline int del(const int &x,const int &y){
return (x-y<0?x-y+mod:x-y);
}
int ksm(int x,int k){
int base=1;
while(k){
if(k&1)base=1ll*base*x%mod;
k>>=1;
x=1ll*x*x%mod;
}
return base;
}
};
using namespace CFConTest;
const int N=2e5+5;
const int M=2e5;
int n,m;
//int f[2][N][N];
int fac[N],ifac[N];
int C(int x,int y){
return 1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod;
}
signed main(){
#ifdef newbiewzs
double startt=clock();
freopen("data.in","r",stdin);
#else
#endif
n=read();m=read();
/* for(int i=1;i<=m;i++)f[1][1][i]=1;
for(int i=2;i<=n;i++){
memset(f[i&1],0,sizeof(f[i&1]));
for(int k=1;k<=m;k++){
for(int j=k;j<=m;j++){
for(int x=k;x<=j;x++){
for(int y=j;y<=m;y++){
f[i&1][x][y]=add(f[i&1][x][y],f[(i-1)&1][k][j]);
}
}
}
}
}
for(int i=1;i<=m;i++){
ans=add(ans,f[n&1][i][m]);
}*/
int tmp=n+m;
int pre=((tmp-2)*(tmp-1)/2);
pre+=n;
int xx,yy;
for(int i=1;i<=M;i++){
if(pre>i)pre-=i;
else {
xx=i;yy=pre;
break;
}
}
fac[0]=ifac[0]=1;
for(int i=1;i<=M;i++)fac[i]=1ll*fac[i-1]*i%mod;
ifac[M]=ksm(fac[M],mod-2);
for(int i=M-1;i>=1;i--)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
int ans=1ll*C(xx-1,yy-1)*C(xx,yy-1)%mod*ksm(yy,mod-2)%mod;
cout<<ans<<'\n';
#ifdef newbiewzs
double endd=clock();
cerr<<'\n';
cerr<<"Time:"<<endd-startt<<" ms"<<'\n';
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 6808kb
input:
2 2
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 2ms
memory: 7076kb
input:
2 4
output:
10
result:
ok 1 number(s): "10"
Test #3:
score: 0
Accepted
time: 2ms
memory: 7196kb
input:
100 100
output:
818380736
result:
ok 1 number(s): "818380736"
Test #4:
score: 0
Accepted
time: 5ms
memory: 7156kb
input:
1 1
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 2ms
memory: 8576kb
input:
1 2
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 6ms
memory: 8680kb
input:
1 3
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 0
Accepted
time: 6ms
memory: 7628kb
input:
1 4
output:
1
result:
ok 1 number(s): "1"
Test #8:
score: 0
Accepted
time: 5ms
memory: 6720kb
input:
1 5
output:
1
result:
ok 1 number(s): "1"
Test #9:
score: 0
Accepted
time: 2ms
memory: 7812kb
input:
2 1
output:
1
result:
ok 1 number(s): "1"
Test #10:
score: 0
Accepted
time: 5ms
memory: 8076kb
input:
2 2
output:
3
result:
ok 1 number(s): "3"
Test #11:
score: 0
Accepted
time: 5ms
memory: 7704kb
input:
2 3
output:
6
result:
ok 1 number(s): "6"
Test #12:
score: 0
Accepted
time: 0ms
memory: 7192kb
input:
2 4
output:
10
result:
ok 1 number(s): "10"
Test #13:
score: 0
Accepted
time: 2ms
memory: 8400kb
input:
2 5
output:
15
result:
ok 1 number(s): "15"
Test #14:
score: 0
Accepted
time: 6ms
memory: 7300kb
input:
3 1
output:
1
result:
ok 1 number(s): "1"
Test #15:
score: 0
Accepted
time: 2ms
memory: 8168kb
input:
3 2
output:
6
result:
ok 1 number(s): "6"
Test #16:
score: 0
Accepted
time: 6ms
memory: 8628kb
input:
3 3
output:
20
result:
ok 1 number(s): "20"
Test #17:
score: 0
Accepted
time: 5ms
memory: 8028kb
input:
3 4
output:
50
result:
ok 1 number(s): "50"
Test #18:
score: 0
Accepted
time: 2ms
memory: 8708kb
input:
3 5
output:
105
result:
ok 1 number(s): "105"
Test #19:
score: 0
Accepted
time: 1ms
memory: 7248kb
input:
4 1
output:
1
result:
ok 1 number(s): "1"
Test #20:
score: 0
Accepted
time: 2ms
memory: 8332kb
input:
4 2
output:
10
result:
ok 1 number(s): "10"
Test #21:
score: 0
Accepted
time: 5ms
memory: 6976kb
input:
4 3
output:
50
result:
ok 1 number(s): "50"
Test #22:
score: 0
Accepted
time: 5ms
memory: 7328kb
input:
4 4
output:
175
result:
ok 1 number(s): "175"
Test #23:
score: 0
Accepted
time: 6ms
memory: 7276kb
input:
4 5
output:
490
result:
ok 1 number(s): "490"
Test #24:
score: 0
Accepted
time: 6ms
memory: 7512kb
input:
5 1
output:
1
result:
ok 1 number(s): "1"
Test #25:
score: 0
Accepted
time: 5ms
memory: 8292kb
input:
5 2
output:
15
result:
ok 1 number(s): "15"
Test #26:
score: 0
Accepted
time: 5ms
memory: 7876kb
input:
5 3
output:
105
result:
ok 1 number(s): "105"
Test #27:
score: 0
Accepted
time: 5ms
memory: 7972kb
input:
5 4
output:
490
result:
ok 1 number(s): "490"
Test #28:
score: 0
Accepted
time: 5ms
memory: 6856kb
input:
5 5
output:
1764
result:
ok 1 number(s): "1764"
Test #29:
score: 0
Accepted
time: 3ms
memory: 7260kb
input:
1 9
output:
1
result:
ok 1 number(s): "1"
Test #30:
score: 0
Accepted
time: 2ms
memory: 7716kb
input:
8 4
output:
4950
result:
ok 1 number(s): "4950"
Test #31:
score: 0
Accepted
time: 6ms
memory: 8532kb
input:
2 48
output:
1176
result:
ok 1 number(s): "1176"
Test #32:
score: 0
Accepted
time: 2ms
memory: 8652kb
input:
57 4
output:
278114495
result:
ok 1 number(s): "278114495"
Test #33:
score: 0
Accepted
time: 2ms
memory: 7184kb
input:
82 51
output:
501711451
result:
ok 1 number(s): "501711451"
Test #34:
score: 0
Accepted
time: 5ms
memory: 7968kb
input:
4909 1
output:
1
result:
ok 1 number(s): "1"
Test #35:
score: 0
Accepted
time: 5ms
memory: 8356kb
input:
30 3890
output:
146479684
result:
ok 1 number(s): "146479684"
Test #36:
score: 0
Accepted
time: 2ms
memory: 6756kb
input:
2081 3619
output:
991511011
result:
ok 1 number(s): "991511011"
Test #37:
score: 0
Accepted
time: 6ms
memory: 8556kb
input:
9511 10
output:
282597455
result:
ok 1 number(s): "282597455"
Test #38:
score: 0
Accepted
time: 2ms
memory: 6904kb
input:
21 36014
output:
305749705
result:
ok 1 number(s): "305749705"
Test #39:
score: 0
Accepted
time: 2ms
memory: 6808kb
input:
10049 6765
output:
275321949
result:
ok 1 number(s): "275321949"
Test #40:
score: 0
Accepted
time: 2ms
memory: 6988kb
input:
13036 23902
output:
885509275
result:
ok 1 number(s): "885509275"
Test #41:
score: 0
Accepted
time: 5ms
memory: 8408kb
input:
1 100000
output:
1
result:
ok 1 number(s): "1"
Test #42:
score: 0
Accepted
time: 6ms
memory: 7296kb
input:
100000 1
output:
1
result:
ok 1 number(s): "1"
Test #43:
score: 0
Accepted
time: 3ms
memory: 7152kb
input:
98765 95678
output:
302812642
result:
ok 1 number(s): "302812642"
Test #44:
score: 0
Accepted
time: 0ms
memory: 7280kb
input:
100000 100000
output:
174524777
result:
ok 1 number(s): "174524777"