QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#358590#6824. Demonstrational SequencescrsfaaRE 4ms28104kbC++14835b2024-03-19 21:17:372024-03-19 21:17:39

Judging History

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

  • [2024-03-19 21:17:39]
  • 评测
  • 测评结果:RE
  • 用时:4ms
  • 内存:28104kb
  • [2024-03-19 21:17:37]
  • 提交

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;
}
vector<int> t[1<<20];
/*
gcd(a-b,P)=Q
*/
signed main()
{
	int p=read(),q=read(),k=read();
	while(k--)
	{
		int a=read()%p,b=read()%p,i;
		for(i=0;i<q;i++)
			t[i].clear();
		t[a%q].push_back(a);
		for(int T=0;T<1e6;T++)
		{
			a=(a*a+b)%p;
			int w=a%q;
//			cout<<':'<<a<<endl;
			for(auto x:t[w])
			{
				if(__gcd(p,(a-x+p)%p)==q)
				{
					putchar('1');
					goto bre;
				}
				if(x==a)
				{
					putchar('0');
					goto bre;
				}
			}
			t[w].push_back(a);
		}
		putchar('0');
		bre:;
	}
}

详细

Test #1:

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

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: 4ms
memory: 28104kb

input:

998244352 1048576 3
2022 924
12345678 1234567
23333333 6666666

output:

001

result:

ok "001"

Test #3:

score: -100
Runtime Error

input:

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

output:


result: