QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#358076 | #6824. Demonstrational Sequences | crsfaa# | WA | 25ms | 3604kb | C++14 | 952b | 2024-03-19 17:01:42 | 2024-03-19 17:01:42 |
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;
}
/*
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: 3532kb
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: 3580kb
input:
998244352 1048576 3 2022 924 12345678 1234567 23333333 6666666
output:
001
result:
ok "001"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3512kb
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: 0
Accepted
time: 0ms
memory: 3604kb
input:
1000000007 1 200 1244424352052424851 13102057264748565738 10964128241743967010 11238647915096906960 9602909082986968021 14247804011443894396 13231275623402659328 11122445945926639224 1819715673773979255 15011227386780949150 10389668459305004672 13595253579372877142 136927098471150438 141908708541553...
output:
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
result:
ok "111111111111111111111111111111...1111111111111111111111111111111"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
1 1 200 1244422970079336291 4707347560601392081 16633665001192110076 15773758607538398243 11070497290011093392 11929979209055974561 8355738147346006300 6479245221430563815 10109334084151275293 11867087657669754231 17442584295523326999 11181890936205849132 9065910826445511105 4364106058213150008 3158...
output:
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
result:
ok "111111111111111111111111111111...1111111111111111111111111111111"
Test #6:
score: -100
Wrong Answer
time: 25ms
memory: 3544kb
input:
1829276567 1223 200 1244422970077270675 3806627635127557106 13984072790700162529 11560843058580181248 18218320506679528544 11095342096011758221 4400021764111680243 2513593206800052431 18199847053143773541 12194057128449124778 13449463383710867755 15111229049249507634 9142159878193341647 851735763810...
output:
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
result:
wrong answer 1st words differ - expected: '111111111111111111111111111111...1111111111111111111111111111111', found: '111111111111111111111111111111...1111111111111111111111111111111'