QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#358590 | #6824. Demonstrational Sequences | crsfaa | RE | 4ms | 28104kb | C++14 | 835b | 2024-03-19 21:17:37 | 2024-03-19 21:17:39 |
Judging History
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:;
}
}
Details
Tip: Click on the bar to expand more detailed information
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...