QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#358627 | #6824. Demonstrational Sequences | crsfaa | WA | 4ms | 28340kb | C++14 | 1.1kb | 2024-03-19 21:39:54 | 2024-03-19 21:39:54 |
Judging History
answer
#include<bits/stdc++.h>
#define Yukinoshita namespace
#define Yukino std
#define int unsigned 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();
// cout<<a<<' '<<b<<' '<<q<<endl;
int g=__gcd(p,__gcd(a,b));
if(g!=q&&g%q==0)
{
putchar('0');
continue;
}
t[a%q].push_back(a);
for(int T=0;T<q/__gcd(a,b);T++)
{
a=(a*a+b)%p;
int w=a%q;
// cout<<a<<endl;
// cout<<':'<<a<<endl;
for(auto x:t[w])
{
if(__gcd(p,(p-x+a)%p)==q)
{
putchar('1');
goto bre;
}
if(x==a)
{
putchar('0');
goto bre;
}
}
// cout<<t[w].size()<<endl;
t[w].push_back(a);
}
putchar('0');
bre:;
}
}
/*
100237 100237 10
11178595626727644735 679276059713497324
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 28220kb
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: 3ms
memory: 28204kb
input:
998244352 1048576 3 2022 924 12345678 1234567 23333333 6666666
output:
001
result:
ok "001"
Test #3:
score: -100
Wrong Answer
time: 4ms
memory: 28340kb
input:
100237 100237 10 1244422970085542683 6256585832417115176 11178595626727644735 679276059713497324 5646838801370008540 6709514788466664568 9971158657914728691 8724448042786063799 9867649407902336110 2614925263502318093 1990105069810770727 8671216841234378816 7965667786524489724 6722337513023700570 246...
output:
1000110011
result:
wrong answer 1st words differ - expected: '1111111111', found: '1000110011'