QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#19853#2601. Lucky TicketsExplodingKonjac#WA 255ms13864kbC++143.7kb2022-02-12 14:53:202022-05-06 07:21:43

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-06 07:21:43]
  • 评测
  • 测评结果:WA
  • 用时:255ms
  • 内存:13864kb
  • [2022-02-12 14:53:20]
  • 提交

answer

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

namespace FastIO
{
	class FastIOBase
	{
	 protected:
#ifdef OPENIOBUF
		static const int BUFSIZE=1<<22;
		char buf[1<<22];
		int buf_p=0;
#endif
		FILE *target;
	 public:
#ifdef OPENIOBUF
	 	virtual void flush()=0;
#endif
		FastIOBase(FILE *f): target(f){}
		~FastIOBase()=default;
	};

	class FastOutput: public FastIOBase
	{
#ifdef OPENIOBUF
	 public:
		inline void flush()
			{ fwrite(buf,1,buf_p,target),buf_p=0; }
#endif
	 protected:
		inline void __putc(char x)
		{
#ifdef OPENIOBUF
			buf[buf_p++]=x;if(buf_p>=BUFSIZE)flush();
#else
			putc(x,target);
#endif
		}
		template<typename T>
		void __write(const T &x)
		{
			if(x<0)	__putc('-'),__write(-x);
			else	{ if(x>9)__write(x/10);__putc(x%10+'0'); }
		}
	 public:
		FastOutput(FILE *f=stdout): FastIOBase(f){}
		inline FastOutput &operator <<(char x)
			{ return __putc(x),*this; }
		inline FastOutput &operator <<(const char *s)
			{ for(;*s;__putc(*(s++)));return *this; }
		inline FastOutput &operator <<(const string &s)
			{ return (*this)<<s.c_str(); }
		template<typename T,typename=typename enable_if<is_integral<T>::value>::type>
		inline FastOutput &operator <<(const T &x)
			{ return __write(x),*this; }
		template<typename ...T>
		inline void writesp(const T &...x)
			{ int var[]={(this->operator<<(x),__putc(' '),0)...}; }
		template<typename ...T>
		inline void writeln(const T &...x)
			{ int var[]={(this->operator<<(x),__putc('\n'),0)...}; }
	}qout;

	class FastInput: public FastIOBase
	{
#ifdef OPENIOBUF
	 public:
		inline void flush()
			{ fread(buf,1,BUFSIZE,target),buf_p=0; }
#endif
	 private:
		char ch,sym;
		static char str_buf[1<<22];
	 protected:
	 	inline char __getc()
		{
#ifdef OPENIOBUF
			if(!buf_p || buf_p>=BUFSIZE)flush();return buf[buf_p++];
#else
			return getc(target);
#endif
		}
	 public:
		FastInput(FILE *f=stdin): FastIOBase(f){}
		inline char getchar()
			{ return __getc(); }
		inline FastInput &operator >>(char &x)
			{ while((x=__getc())<33);return *this; }
		template<typename T,typename=typename enable_if<is_integral<T>::value>::type>
		inline FastInput &operator >>(T &x)
		{
			x=0,sym=1;
			while((ch=__getc())<33);if(ch=='-')sym=-1,ch=__getc();
			for(;ch>='0'&&ch<='9';x*=10,x+=(ch^48),ch=__getc());
			return x*=sym,*this;
		}
		inline FastInput &operator >>(char *s)
		{
			while((*s=__getc())<33);
			for(;*s>32;*(++s)=__getc());
			return *s='\0',*this;
		}
		inline FastInput &operator >>(string &s)
		{
			char *p=str_buf;
			while((*p=__getc())<33);for(;*p>32;*(++p)=__getc());
			*p='\0',s=str_buf;
			return *this;
		}
		template<typename ...T>
		inline void read(T &...x)
			{ int var[]={(this->operator>>(x),0)...}; }
	}qin;
	char FastInput::str_buf[1<<22]="";
}
using namespace FastIO;
typedef long long LL;
int n,s,q,ans,MOD;
inline LL quickPow(LL a,LL b,int mod=MOD)
{
	LL res=1;
	for(;b;a=a*a%mod,b>>=1)if(b&1)res=res*a%mod;
	return res;
}
inline int madd(int x,int y)	{ return (x+=y)>=MOD?(x-=MOD):x; }
inline int msub(int x,int y)	{ return (x-=y)<0?(x+=MOD):x; }
inline int mmul(int x,int y)	{ return (LL)x*y%MOD; }
inline int mdiv(int x,int y)	{ return (LL)x*quickPow(y,MOD-2)%MOD; }
int lim,tmp,fac[2000005],inv[2000005];
int main()
{
	qin>>n>>s>>q,MOD=q,lim=n+q;
	fac[0]=1;
	for(int i=1;i<=lim;i++)	fac[i]=mmul(fac[i-1],i);
	inv[lim]=quickPow(fac[lim],MOD-2);
	for(int i=lim;i>=1;i--)	inv[i-1]=mmul(inv[i],i);
	tmp=msub(quickPow(2,q),1);
	for(int i=0;i<n;i++)
		if((LL)(i*q+quickPow(i,q,n))%n==s)
			ans=madd(ans,madd(mmul(fac[q+i],inv[i]),mmul(tmp,i)));
	qout<<ans;
//	return qout.flush(),0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 3464kb

input:

2 0 2

output:

0

result:

ok 1 number(s): "0"

Test #2:

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

input:

10 9 2

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

3 2 3

output:

2

result:

ok 1 number(s): "2"

Test #4:

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

input:

2 1 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

4 0 3

output:

1

result:

ok 1 number(s): "1"

Test #6:

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

input:

4 2 3

output:

2

result:

ok 1 number(s): "2"

Test #7:

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

input:

20 4 19

output:

5

result:

ok 1 number(s): "5"

Test #8:

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

input:

30 2 37

output:

23

result:

ok 1 number(s): "23"

Test #9:

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

input:

87 22 67

output:

0

result:

ok 1 number(s): "0"

Test #10:

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

input:

829 135 857

output:

803

result:

ok 1 number(s): "803"

Test #11:

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

input:

6120 2790 9851

output:

4622

result:

ok 1 number(s): "4622"

Test #12:

score: 0
Accepted
time: 21ms
memory: 4724kb

input:

77263 13087 50147

output:

26904

result:

ok 1 number(s): "26904"

Test #13:

score: -100
Wrong Answer
time: 255ms
memory: 13864kb

input:

682298 437284 638801

output:

394124

result:

wrong answer 1st numbers differ - expected: '10038', found: '394124'