QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#358073#6824. Demonstrational Sequencescrsfaa#WA 0ms3516kbC++14942b2024-03-19 17:00:252024-03-19 17:00:25

Judging History

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

  • [2024-03-19 17:00:25]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3516kb
  • [2024-03-19 17:00:25]
  • 提交

answer

#include<bits/stdc++.h>
#define Yukinoshita namespace
#define Yukino std
#define int long long
using Yukinoshita Yukino;
int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') w=ch=='-'?-1:1,ch=getchar();
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
/*
998244352 1048576 3
*/
signed main()
{
	int p=read(),q=read(),k=read(),i;
	while(k--)
	{
		int a=read()%p,b=read()%p;
		if(p==q)
		{
			putchar('1');
			continue;
		}
		if(__gcd(__gcd(a,b),p)!=q&&__gcd(__gcd(a,b),p)%q==0)
		{
			putchar('0');
			continue;	
		}
		set<int> st{a};
		for(;;)
		{
			a=(1ll*a*a+b)%p;
			if(st.size()>2000)
			{
				putchar('1');
				break;
			}
			if(st.count(a))
			{
				putchar('0');
				break;
			}
			for(auto x:st)
				if(__gcd((a-x+p)%p,p)==q)
				{
					putchar('1');
					goto bre;
				}
//			cout<<a<<',';
			st.insert(a);
		}
		bre:;
//		puts("");	
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

15 5 5
1 1
1 2
2 4
4 8
8 16

output:

11010

result:

ok "11010"

Test #2:

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

input:

998244352 1048576 3
2022 924
12345678 1234567
23333333 6666666

output:

001

result:

ok "001"

Test #3:

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

input:

100237 100237 10
1244422970085542683 6256585832417115176
11178595626727644735 679276059713497324
5646838801370008540 6709514788466664568
9971158657914728691 8724448042786063799
9867649407902336110 2614925263502318093
1990105069810770727 8671216841234378816
7965667786524489724 6722337513023700570
246...

output:

1111111111

result:

ok "1111111111"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3500kb

input:

1000000007 1 200
1244424352052424851 13102057264748565738
10964128241743967010 11238647915096906960
9602909082986968021 14247804011443894396
13231275623402659328 11122445945926639224
1819715673773979255 15011227386780949150
10389668459305004672 13595253579372877142
136927098471150438 141908708541553...

output:

10001101110110101101110101110100010011001111011101100111110010111010110001101000000100111001011111100010100111111011001110111011111101101101001010110110100111101011111111111110001011001101101101011001

result:

wrong answer 1st words differ - expected: '111111111111111111111111111111...1111111111111111111111111111111', found: '100011011101101011011101011101...1111110001011001101101101011001'