QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#322234#8171. ColaEXODUSWA 174ms160220kbC++142.3kb2024-02-06 16:22:112024-02-06 16:22:11

Judging History

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

  • [2024-02-06 16:22:11]
  • 评测
  • 测评结果:WA
  • 用时:174ms
  • 内存:160220kb
  • [2024-02-06 16:22:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

#define rep(i,l,r) for(int i(l);i<=(r);++i)
#define per(i,r,l) for(int i(r);i>=(l);--i)
#define eb emplace_back
#define File(filename) freopen(filename ".in","r",stdin),freopen(filename ".out","w",stdout)
#define Exit(p) fprintf(stderr,"[exit]: at breakpoint %d\n",p),exit(0);

#ifdef EXODUS
	#define Debug(...) fprintf(stderr,__VA_ARGS__)
#else
	#define Debug(...) 0
#endif

//=========================================================================================================
// Something about IO

template<typename T>
void read(T &x){
	x=0;T flg=1;
	char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')flg=-1;ch=getchar();}
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	x*=flg;
}
template<typename T,typename... Args>
void read(T &x,Args &...args){read(x),read(args...);}

//=========================================================================================================
// Define the global variables here.

bool membg=0;

constexpr int N=2e7+7,mod=998244353;
int n,m,fac[N],ifac[N],ans;

bool memed=0;

//=========================================================================================================
// Code here.

int binom(int x,int y){
	return (ll)fac[x]*ifac[y]%mod*ifac[x-y]%mod;
}

int query(int x){
	if(x<0)return 0;
	return binom(x+n,n);
}

int qp(int x,int y){
	int res=1;
	for(;y;y>>=1,x=(ll)x*x%mod)
		if(y&1)res=(ll)res*x%mod;
	return res;
}

void solve(){
	read(n,m),m--;
	fac[0]=1;
	for(int i=1;i<N;i++)fac[i]=(ll)fac[i-1]*i%mod;
	ifac[N-1]=qp(fac[N-1],mod-2);
	for(int i=N-2;i>=0;i--)ifac[i]=(ll)ifac[i+1]*(i+1)%mod;
	ans=query(m);
	for(int k=1;k*(3*k-1)/2<=m;++k)
		ans=(ans+(k&1?mod-1:1)*(query(m-k*(3*k-1)/2)+query(m-k*(3*k+1)/2)))%mod;
	ans=(ll)ans*ifac[n]%mod;
	printf("%d\n",ans);
	return;
}


//=========================================================================================================

int main(){
	Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
	int timbg=clock();
	int T=1;
	while(T--)solve();
	int timed=clock();
	Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
	fflush(stdout);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 174ms
memory: 160104kb

input:

2 1

output:

499122177

result:

ok "499122177"

Test #2:

score: 0
Accepted
time: 157ms
memory: 160220kb

input:

1 1

output:

1

result:

ok "1"

Test #3:

score: -100
Wrong Answer
time: 171ms
memory: 160156kb

input:

167 91

output:

426078481

result:

wrong answer 1st words differ - expected: '469117530', found: '426078481'