QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#621833#8147. Math ExamWrongAnswer_90AC ✓172ms240324kbC++175.9kb2024-10-08 17:23:032024-10-08 17:23:04

Judging History

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

  • [2024-10-08 17:23:04]
  • 评测
  • 测评结果:AC
  • 用时:172ms
  • 内存:240324kb
  • [2024-10-08 17:23:03]
  • 提交

answer

#include<bits/stdc++.h>
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define ll long long
#define lll __int128
#define fi first
#define se second
#define e emplace
#define eb emplace_back
#define db double
#define ef emplace_front
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vp vector<pii>
#define vt vector<tup>
#define all(x) x.begin(),x.end()
#define mp make_pair

#define FastI
#define FastO
#define int ll
bool ST;
static const ll MOD=998244353,Phi=998244352,inv2=499122177,Root=3,iRoot=332748118;
static const ll inf=1073741823,Inf=4294967296,INF=4557430888798830399;
static const ld eps=1e-9,pi=3.1415926535;
char in[1<<20],*p1=in,*p2=in;
char out[1<<20],*p3=out;
using namespace std;
struct tup
{
	int x,y,z;
	tup(int X=0,int Y=0,int Z=0)
	{x=X,y=Y,z=Z;}
};
#ifdef FastI
#define getchar() (p1==p2&&(p2=(p1=in)+fread(in,1,1<<20,stdin),p1==p2)?EOF:*p1++)
#endif
#ifdef FastO
#define putchar(x) (p3-out==1<<20?fwrite(out,1,1<<20,stdout),p3=out,0:0,*p3++=x)
#define puts(x) write(x,'\n')
#endif
namespace FastIO
{
	template<typename T> inline void write(T x,char ch=' ')
	{
		if(is_same<char,T>::value)putchar(x);
		else
		{
			if(x<0)x=-x,putchar('-');
			static char st[25];
			int top=0;
			do st[top++]=x%10+'0',x/=10;while(x);
			while(top)putchar(st[--top]);
		}
		ch!='~'?putchar(ch):0;
	}
	inline void write(const char*x,char ch=' ')
	{
		for(int i=0;x[i]!='\0';++i)putchar(x[i]);
		ch!='~'?putchar(ch):0;
	}
	inline void read(char&s){do s=getchar();while(s=='\n'||s==' ');}
	inline void read(char s[])
	{
		int len=0;char st;
		do st=getchar();while(st=='\n'||st==' ');
		s[++len]=st,st=getchar();
		while(st!='\n'&&st!=' ')s[++len]=st,st=getchar();
		s[++len]='\0';
	}
	template<typename T> inline void read(T &s)
	{
		char ch=getchar();s=0;
		while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
		bool tf=(ch=='-'&&(ch=getchar()));
		while(ch>='0'&&ch<='9')s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
		s=tf?-s:s;
	}
	inline void edl(){putchar('\n');}
	template<typename T1,typename T2> inline void read(pair<T1,T2> &s){read(s.fi),read(s.se);}
	template<typename T,typename...Args> inline void write(T x,Args...args){write(x,'~'),write(args...);}
	template<typename T,typename...Args> inline void read(T&x,Args&...args){read(x),read(args...);}
	#ifdef FastO
	struct Writer{~Writer(){fwrite(out,1,p3-out,stdout);}}Writ;
	#endif
}
using namespace FastIO;
namespace MTool
{
	inline int Cadd(int a,int b){return (ll)a+b>=MOD?(ll)a+b-MOD:a+b;}
	inline int Cdel(int a,int b){return a-b<0?a-b+MOD:a-b;}
	inline int Cmul(int a,int b){return 1ll*a*b%MOD;}
	inline int sqr(int a){return 1ll*a*a%MOD;}
	inline void Madd(int&a,int b){a=((ll)a+b>=MOD?(ll)a+b-MOD:a+b);}
	inline void Mdel(int&a,int b){a=(a-b<0?a-b+MOD:a-b);}
	inline void Mmul(int&a,int b){a=1ll*a*b%MOD;}
	inline int Cmod(int x){return (x%MOD+MOD)%MOD;}
	inline void Mmod(int&x){x=(x%MOD+MOD)%MOD;}
	template<typename T> inline bool Mmax(T&a,T b){return a<b?a=b,1:0;}
	template<typename T> inline bool Mmin(T&a,T b){return a>b?a=b,1:0;}
	template<typename...Args> inline void Madd(int&a,int b,Args...args){Madd(a,b),Madd(a,args...);}
	template<typename...Args> inline void Mmul(int&a,int b,Args...args){Mmul(a,b),Mmul(a,args...);}
	template<typename...Args> inline void Mdel(int&a,int b,Args...args){Mdel(a,b),Mdel(a,args...);}
	template<typename...Args> inline int Cadd(int a,int b,Args...args){return Cadd(Cadd(a,b),args...);}
	template<typename...Args> inline int Cmul(int a,int b,Args...args){return Cmul(Cmul(a,b),args...);}
	template<typename...Args> inline int Cdel(int a,int b,Args...args){return Cdel(Cdel(a,b),args...);}
	template<typename...Args,typename T> inline bool Mmax(T&a,T b,Args...args){return Mmax(a,b)|Mmax(a,args...);}
	template<typename...Args,typename T> inline bool Mmin(T&a,T b,Args...args){return Mmin(a,b)|Mmin(a,args...);}
	inline int power(int x,int y){int s=1;for(;y;y>>=1,Mmul(x,x))if(y&1)Mmul(s,x);return s;}
}
using namespace MTool;
namespace WrongAnswer_90
{
	int fr[10000010],inv[10000010];
	int c[10000010];
	inline int C(int n,int m){return m<0||m>n?0:Cmul(fr[n],inv[m],inv[n-m]);}
	int lx,rx;
	inline void mian()
	{
		int n,m;
		read(n,m);
		m=(m+1)>>1;
		++m;
		
		int lx=((n-m)>>1)+1;
		int rx=n>>1;
		c[lx]++;
		c[rx+1]--;
//		cerr<<lx<<" "<<rx<<endl;exit(0);
		
//		for(int i=0;i<=n;++i)write(c[i]);puts("");
		int x=0,y=0;
		while(1)
		{
			int xx=y+1,yy=x-1;
			x=xx,y=yy;
			if(lx-x>n)break;
			if(x>rx)break;
//			cerr<<x<<" "<<y<<endl;
			c[max(0ll,lx-x)]--;
			c[min(n,rx-x)+1]++;
			xx=y-m,yy=x+m;
			x=xx,y=yy;
			if(lx-x>n)break;
			if(x>rx)break;
//			cerr<<x<<" "<<y<<endl;
			c[max(0ll,lx-x)]++;
			c[min(n,rx-x)+1]--;
		}
//		for(int i=0;i<=n;++i)write(c[i]);puts("");
//		exit(0);
		
		x=0,y=0;
		while(1)
		{
			int xx=y-m,yy=x+m;
			x=xx,y=yy;
			if(lx-x>n)break;
			if(x>rx)break;
//			cerr<<x<<" "<<y<<endl;
			c[max(0ll,lx-x)]--;
			c[min(n,rx-x)+1]++;
			xx=y+1,yy=x-1;
			x=xx,y=yy;
			if(lx-x>n)break;
			if(x>rx)break;
//			cerr<<x<<" "<<y<<endl;
			c[max(0ll,lx-x)]++;
			c[min(n,rx-x)+1]--;
		}
		
		for(int i=1;i<=n;++i)
		{
			Madd(c[i],c[i-1]);
			c[i]=(c[i]+MOD)%MOD;
		}
		int ans=0;
		for(int i=0;i<=n;++i)
		Madd(ans,Cmul(c[i],C(n,i)));
		write(ans);
	}
	inline void Mian()
	{
		fr[0]=1,inv[0]=1;
		for(int i=1;i<=10000005;++i)fr[i]=Cmul(fr[i-1],i);
		inv[10000005]=power(fr[10000005],MOD-2);
		for(int i=10000004;i>0;--i)inv[i]=Cmul(inv[i+1],i+1);
		int T=1;
//		read(T);
		while(T--)mian();
	}
}
bool ED;
signed main()
{
//	ios::sync_with_stdio(0); 
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	double st=clock();
	WrongAnswer_90::Mian();
	double ed=clock();
 	cerr<<endl;
 	cerr<<"Time: "<<ed-st<<" ms\n";
 	cerr<<"Memory: "<<abs(&ST-&ED)/1024.0/1024.0<<" MB\n";
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 63ms
memory: 160784kb

input:

9 13

output:

124 

result:

ok answer is '124'

Test #2:

score: 0
Accepted
time: 87ms
memory: 162172kb

input:

500 999

output:

195157058 

result:

ok answer is '195157058'

Test #3:

score: 0
Accepted
time: 164ms
memory: 238372kb

input:

10000000 19260817

output:

475124613 

result:

ok answer is '475124613'

Test #4:

score: 0
Accepted
time: 71ms
memory: 172928kb

input:

1234567 654321

output:

986926700 

result:

ok answer is '986926700'

Test #5:

score: 0
Accepted
time: 87ms
memory: 174488kb

input:

1145141 11451

output:

186897097 

result:

ok answer is '186897097'

Test #6:

score: 0
Accepted
time: 84ms
memory: 162540kb

input:

114514 11451

output:

91839230 

result:

ok answer is '91839230'

Test #7:

score: 0
Accepted
time: 90ms
memory: 171164kb

input:

1145143 114555

output:

641840034 

result:

ok answer is '641840034'

Test #8:

score: 0
Accepted
time: 90ms
memory: 180620kb

input:

2123181 1980523

output:

784155222 

result:

ok answer is '784155222'

Test #9:

score: 0
Accepted
time: 128ms
memory: 194568kb

input:

4238693 1876847

output:

169222558 

result:

ok answer is '169222558'

Test #10:

score: 0
Accepted
time: 164ms
memory: 225948kb

input:

7804655 10519823

output:

935955279 

result:

ok answer is '935955279'

Test #11:

score: 0
Accepted
time: 172ms
memory: 236176kb

input:

9189568 17055313

output:

811181659 

result:

ok answer is '811181659'

Test #12:

score: 0
Accepted
time: 87ms
memory: 167728kb

input:

683534 1001003

output:

569208897 

result:

ok answer is '569208897'

Test #13:

score: 0
Accepted
time: 113ms
memory: 176112kb

input:

1850342 3700683

output:

852266054 

result:

ok answer is '852266054'

Test #14:

score: 0
Accepted
time: 155ms
memory: 240324kb

input:

10000000 1234567

output:

387622638 

result:

ok answer is '387622638'

Test #15:

score: 0
Accepted
time: 80ms
memory: 161652kb

input:

1 1

output:

1 

result:

ok answer is '1'

Test #16:

score: 0
Accepted
time: 83ms
memory: 161656kb

input:

3 1

output:

1 

result:

ok answer is '1'

Test #17:

score: 0
Accepted
time: 169ms
memory: 238592kb

input:

10000000 1

output:

1 

result:

ok answer is '1'

Extra Test:

score: 0
Extra Test Passed