QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#358622 | #6824. Demonstrational Sequences | crsfaa | TL | 1809ms | 42628kb | C++14 | 1.0kb | 2024-03-19 21:37:51 | 2024-03-19 21:37:52 |
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*20;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;
}
}
t[w].push_back(a);
}
putchar('0');
bre:;
}
}
/*
100237 100237 10
11178595626727644735 679276059713497324
*/
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 28256kb
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: 7ms
memory: 28236kb
input:
998244352 1048576 3 2022 924 12345678 1234567 23333333 6666666
output:
001
result:
ok "001"
Test #3:
score: 0
Accepted
time: 4ms
memory: 28364kb
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: 3ms
memory: 28176kb
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: 28160kb
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: 0
Accepted
time: 26ms
memory: 28244kb
input:
1829276567 1223 200 1244422970077270675 3806627635127557106 13984072790700162529 11560843058580181248 18218320506679528544 11095342096011758221 4400021764111680243 2513593206800052431 18199847053143773541 12194057128449124778 13449463383710867755 15111229049249507634 9142159878193341647 851735763810...
output:
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101111111111111111111111111111111111111111111111111111111111111111111111
result:
ok "111111111111111111111111111111...1111111111111111111111111111111"
Test #7:
score: 0
Accepted
time: 7ms
memory: 29160kb
input:
1916775961 43781 200 1244422991562533611 2581648536462341184 10846740824576506379 9993690399888017205 8345302117372117052 12258730889585496219 6487130277971010241 11996418174856728756 8151541988194450093 17962020692109166031 5265702935744667861 3426174342122309619 3337825504340444832 108442264083652...
output:
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
result:
ok "111111111111111111111111111111...1111111111111111111111111111111"
Test #8:
score: 0
Accepted
time: 17ms
memory: 29144kb
input:
1992104689 44633 200 1244423004569553187 708151091329533332 9122468538725959348 6266937734283537059 17378118143373524488 14143033550582754474 9766586826768167785 1594616520143492866 734438740803221400 11158266026263179425 460036223567287536 4242791159789103332 17830443150457246178 422414602667113372...
output:
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
result:
ok "111111111111111111111111111111...1111111111111111111111111111111"
Test #9:
score: 0
Accepted
time: 23ms
memory: 29728kb
input:
200474 100237 200 1244422970085542683 6256585832417115176 11178595626727644735 679276059713497324 15646838801370008540 16709514788466664568 9971158657914728691 8724448042786063799 9867649407902336110 2614925263502318093 1990105069810770727 8671216841234378816 17965667786524489724 6722337513023700570...
output:
00000000111111010001100001000000010001111000110000000010001010010000100001001001010100100011010000100000100110100000000000001000000010000000000000000000000100010000010000001000000010000000010110000000
result:
ok "000000001111110100011000010000...0001000000010000000010110000000"
Test #10:
score: 0
Accepted
time: 7ms
memory: 28176kb
input:
200474 2 200 1244422970290369323 10652099068730767710 8319150041957358027 4252860857770083514 2283720720491098640 10687885864933740120 2825325290598596007 6440406404796000441 6950945943062257465 15095351257240999518 2718104921152369583 1084988046635922392 16727496739401426409 4394616015239803414 169...
output:
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
result:
ok "111111111111111111111111111111...1111111111111111111111111111111"
Test #11:
score: 0
Accepted
time: 175ms
memory: 32048kb
input:
4263743276 45077 200 1623855933086673195 1394720197804715148 594107206097182228 18010286562889463890 9232604372259259000 11733065843529966425 5391787691872768215 17960957873981251752 3586770739608645055 9993896394458670052 13988642877924042007 4434275232993882359 17191799348415529968 309677586807292...
output:
00000000000000000001000000000100000000000000000000000000000000000000000000000000000000000010010000000000000000100000000000000000000000100000000000000010000001000000000000100000000000000000000000000000
result:
ok "000000000000000000010000000001...0100000000000000000000000000000"
Test #12:
score: 0
Accepted
time: 308ms
memory: 33828kb
input:
2243653896 79427 200 7085613735056938731 7108859055092139649 5695922196596095831 16949890178661708151 990145800953174351 16245094806650297114 14882674693247816808 11363366359950489284 7394995576056186215 2589960776998221148 8800920093793606635 1967301338500188756 8024931924200017420 2272503502062228...
output:
00000000010000000000000100000000000000010000000000000000000000000000010000000000001100001000000000000000000000000000000001001000000000000000000000000000000000000000000000010000000000000000000000000000
result:
ok "000000000100000000000001000000...0010000000000000000000000000000"
Test #13:
score: 0
Accepted
time: 262ms
memory: 38876kb
input:
2890356642 644881 200 3338746092145011427 2383740701170010876 2950669909698463161 11412658585846770980 9581681182959202729 12394854403860355917 11974501157757355058 11637902927865695413 17106521716400010010 10095864596609543535 17286559350838320107 9093692469284348154 7890467507278881429 33121849106...
output:
00000000000100000000000000000000000000000000000010000000100000000000001000000000000000001000000000000000000000000000010000000100101000001100000010000000000000000000000000000000000000000000100000000000
result:
ok "000000000001000000000000000000...0000000000000000000100000000000"
Test #14:
score: 0
Accepted
time: 243ms
memory: 36016kb
input:
1800396632 214129 200 11981151872260927763 880061793948709214 3421011936831395463 12066611705686951714 16269052760398633712 17446962064910375058 16831508813820937321 11050585060190750711 16932844042935971401 12586068229506586939 11411308914722614205 1200292887132725511 10614703641719321462 232217329...
output:
00000000000000110011100000011001111000000010100000100000100000000000000100000000001100010100000110100000000000101000010110000000001001011100001010000010010000100000001001100000000001000001001100011001
result:
ok "000000000000001100111000000110...1100000000001000001001100011001"
Test #15:
score: 0
Accepted
time: 1809ms
memory: 42628kb
input:
3015370282 183439 200 10761746441729398571 10660863783446868085 15532810238104375115 13584557295679235643 14578065710103350759 8400985091796697052 4806777690723159905 16714839711297371203 11465540402873333574 18426053423616298971 9490365436480928555 5683725064365786074 14141155268528021944 164781404...
output:
00001000001101000100000001101010001100000011000001010000001000000010000000000000000000100000111000011001001000110110010000000010000000001000110000011001100100000001000000001010000010000000001100100010
result:
ok "000010000011010001000000011010...0001010000010000000001100100010"
Test #16:
score: -100
Time Limit Exceeded
input:
3010226974 38669 200 6229984487236849875 11253164618458158674 933313251596761837 1457608186440777540 8513825683200214409 13042665712294984385 18021434368478935104 3106051298410513939 1337957873492806031 448188000892022312 13559383547127008999 16444342020353803624 4597962444641028423 1395535421245956...