QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#212878 | #6824. Demonstrational Sequences | nameless_story# | WA | 2846ms | 13672kb | C++23 | 940b | 2023-10-13 21:54:16 | 2023-10-13 21:54:17 |
Judging History
answer
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;
template<class T1,class T2> bool cmax(T1 &x,const T2 &y) { if (x<y) { x=y; return 1; }return 0; }
#define all(x) (x).begin(),(x).end()
const int N=1e7+2,M=2000;
bool ed[N];
ll c[M+1];
int main()
{
ios::sync_with_stdio(0); cin.tie(0);
cout<<fixed<<setprecision(15);
ll p,q,i,j;
int T;
cin>>p>>q>>T;
p/=q;
map<pair<ll,ll>,int> ans;
for (i=0; i<N; i++) if (gcd(i,p)==1) ed[i]=1;
p*=q;
while (T--)
{
auto cal=[&]()
{
ll a,b,d,dmq;
cin>>a>>b;
// a=8; b=16;
a%=p; b%=p;
if (ans.count({a,b})) return ans[{a,b}];
c[0]=a;
for (i=1; i<=M; i++) c[i]=(c[i-1]*c[i-1]+b)%p;
for (i=0; i<=M; i++) for (j=i+1; j<=M; j++)
{
d=(c[j]+p-c[i])%p;
dmq=d/q;
if (d==dmq*q&&dmq<N&&ed[dmq]) return ans[{a,b}]=1;
}
return ans[{a,b}]=0;
};
cout<<cal();
}
cout<<endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 238ms
memory: 13584kb
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: 399ms
memory: 13412kb
input:
998244352 1048576 3 2022 924 12345678 1234567 23333333 6666666
output:
001
result:
ok "001"
Test #3:
score: 0
Accepted
time: 139ms
memory: 13356kb
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: 882ms
memory: 13428kb
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: 98ms
memory: 13432kb
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: 816ms
memory: 13376kb
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: 964ms
memory: 13368kb
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: 952ms
memory: 13368kb
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: 1979ms
memory: 13604kb
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: 687ms
memory: 13376kb
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: 2846ms
memory: 13672kb
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: 2749ms
memory: 13268kb
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: -100
Wrong Answer
time: 2733ms
memory: 13668kb
input:
2890356642 644881 200 3338746092145011427 2383740701170010876 2950669909698463161 11412658585846770980 9581681182959202729 12394854403860355917 11974501157757355058 11637902927865695413 17106521716400010010 10095864596609543535 17286559350838320107 9093692469284348154 7890467507278881429 33121849106...
output:
00000000000100000000000000000000000000000000000010000000100000000000001000000000000000001000000000000000000000000000010000000100101000001100000010000000000000000000000000000000000000000000000000000000
result:
wrong answer 1st words differ - expected: '000000000001000000000000000000...0000000000000000000100000000000', found: '000000000001000000000000000000...0000000000000000000000000000000'