QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#21324 | #2820. 令人难以忘记的题目名称 | DaBenZhongXiaSongKuaiDi# | AC ✓ | 153ms | 6000kb | C++20 | 1.1kb | 2022-03-04 15:36:12 | 2022-05-08 02:53:08 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int n,p;
int a[N],b[N];
int main(){
scanf("%d%d",&n,&p);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
a[i]%=p;
}
if(n%p){
for(int i=1;i<=n;i++){
if(a[i]!=a[1]){
cout<<"-1\n";
return 0;
}
}
cout<<"1\n";
return 0;
}
int tot=0,qwq=1;
int nn=n;
while(nn%p==0) tot++,nn/=p;
for(int j=1;j<=tot;j++) qwq*=p;
for(int i=1;i<=n;i++){
int x=(i+qwq-1)%n+1;
if(a[i]!=a[x]){
cout<<"-1\n";
return 0;
}
}
int ans=0;
for(int s=tot-1;s>=0;s--){
qwq/=p;
int num=0;
while(num<p){
bool flg=true;
// cout<<"now, s="<<s<<", num="<<num<<", a:"<<endl;
// for(int i=1;i<=n;i++){
// cout<<a[i]<<" ";
// }
// cout<<endl;
for(int i=1;i<=n;i++){
int x=(i+qwq-1)%n+1;
if(a[i]!=a[x]){
flg=false;
break;
}
}
if(!flg){
for(int i=1;i<=n;i++){
int x=(i+qwq-1)%n+1;
b[i]=(a[x]-a[i]+p)%p;
}
for(int i=1;i<=n;i++) a[i]=b[i];
ans+=qwq,num++;
}
else{
break;
}
}
// cout<<s<<" "<<num<<endl;
if(num==p) break;
}
cout<<ans+1;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 107ms
memory: 6000kb
input:
297910 31 113232 54750 68197 111096 34111 93605 123591 18035 81089 116592 24694 31596 60286 93804 59021 38782 20907 112337 52523 99808 71474 60598 132242 65758 78755 58580 4515 138889 92332 154059 2039 74180 53778 93861 30218 87862 32418 153778 129564 113461 138995 154233 145061 44213 116624 72685 8...
output:
29019
result:
ok single line: '29019'
Test #2:
score: 0
Accepted
time: 60ms
memory: 5080kb
input:
199927 13 52801 48028 62033 40411 18787 10457 64030 38976 39983 29283 59272 54070 35711 57301 8063 2699 24975 46904 35961 16871 55509 54281 1971 57 46719 19676 56351 33694 11829 21521 20694 64611 4542 27636 49920 33250 38089 58868 7214 22966 23138 11375 12012 58849 3654 30003 6444 28627 21813 52329 ...
output:
26011
result:
ok single line: '26011'
Test #3:
score: 0
Accepted
time: 18ms
memory: 3840kb
input:
16129 127 281931 95747 242 98458 450593 350007 622537 484971 352978 240516 463745 77547 544562 447386 442624 332152 544680 395885 505598 578750 563068 222964 466680 212797 555662 270097 400150 124488 457478 158019 492745 104239 253841 492767 299543 69168 304574 286803 15807 22458 527177 576366 19682...
output:
13405
result:
ok single line: '13405'
Test #4:
score: 0
Accepted
time: 117ms
memory: 5864kb
input:
77618 197 775478 366954 837330 958049 281800 848668 620217 520786 208593 57306 132821 253429 244030 104814 416437 524019 368068 936480 287811 79785 101237 971010 544347 910876 174062 835641 881333 122632 723661 745975 35364 514127 277939 872537 637198 559568 886179 422553 245278 109423 479610 528396...
output:
36149
result:
ok single line: '36149'
Test #5:
score: 0
Accepted
time: 45ms
memory: 5656kb
input:
130321 19 13443 73980 29835 40598 76923 70565 1901 78569 90820 88225 14467 18511 41846 1852 18988 15231 48189 68023 72711 48395 13239 79546 4230 34030 92209 57404 23930 1253 59099 30748 5816 72539 24198 50148 32602 20580 25701 48983 4159 36004 42207 18615 54508 3532 34963 87972 18750 2636 60971 1090...
output:
129547
result:
ok single line: '129547'
Test #6:
score: 0
Accepted
time: 89ms
memory: 4960kb
input:
149784 79 170166 304877 26628 76012 193091 190810 380582 7871 194421 81732 297317 90107 332944 117642 260958 223365 39696 221571 189317 338458 116361 65247 206641 199013 392493 386817 25450 28234 362932 228613 10944 138047 138379 97897 274318 391686 288698 259820 4443 148340 341438 362111 238449 339...
output:
6030
result:
ok single line: '6030'
Test #7:
score: 0
Accepted
time: 98ms
memory: 4948kb
input:
158420 89 424111 248240 24210 416375 339556 335329 143161 4743 440183 419285 173759 112716 36023 113452 305318 314174 134628 309897 155273 48636 302200 406230 376020 401941 379802 335347 443804 437672 51463 365618 78842 30515 236679 103149 69607 131188 61215 212736 203810 56180 254847 431 168855 358...
output:
7490
result:
ok single line: '7490'
Test #8:
score: 0
Accepted
time: 21ms
memory: 3968kb
input:
31684 89 23744 262439 156802 402292 8664 231913 346639 21940 428913 270162 107277 173968 439259 136073 271405 41982 3795 145335 327809 116991 410953 10141 110157 188219 372146 96393 430757 398554 388973 202000 193521 35504 87152 350385 437749 163822 204985 407158 185696 256818 300032 292918 430708 2...
output:
6253
result:
ok single line: '6253'
Test #9:
score: 0
Accepted
time: 118ms
memory: 4656kb
input:
118810 109 374125 388035 352720 430567 347861 20849 3269 372277 194304 415684 351799 133325 118717 129758 36228 99412 150703 188225 529477 148533 47521 207231 527740 432230 422299 354163 268323 483368 499601 491232 173410 411731 417252 526030 380306 303183 84986 383529 130333 362419 254054 20273 495...
output:
9045
result:
ok single line: '9045'
Test #10:
score: 0
Accepted
time: 44ms
memory: 4172kb
input:
68890 83 224509 70210 367697 355211 301326 344150 134105 162815 278214 409699 125555 69917 271813 250734 247969 276742 2109 36339 123982 404238 291299 94276 397015 118000 367058 15906 230101 321160 403022 238541 252707 275776 308602 205419 215808 258180 134423 413226 5838 60873 56048 194773 130771 3...
output:
4528
result:
ok single line: '4528'
Test #11:
score: 0
Accepted
time: 37ms
memory: 4016kb
input:
34322 131 316442 442839 509727 132702 444490 175025 622560 39769 213310 327313 573708 479064 355786 216821 646738 184890 59416 143545 475766 541736 392674 285531 446810 390217 334872 240248 366317 249565 229978 186086 370607 646363 628902 225337 223774 518134 400413 191199 557871 613640 618354 47656...
output:
15153
result:
ok single line: '15153'
Test #12:
score: 0
Accepted
time: 47ms
memory: 3984kb
input:
51076 113 428785 79035 371868 358546 370952 121091 456869 163510 28651 57886 28679 488664 75192 507144 506760 426581 129826 379676 453919 275210 177208 409532 354993 158031 347226 159745 76365 417535 15972 481782 398874 444753 560706 291764 324234 452749 498940 302249 137228 527626 360087 165798 451...
output:
12253
result:
ok single line: '12253'
Test #13:
score: 0
Accepted
time: 101ms
memory: 5320kb
input:
205379 59 20817 103801 136299 114678 249088 239171 256457 149627 16041 10558 175943 263612 47311 288061 68988 101314 273295 65234 25754 5831 181253 182833 287697 200222 183219 9844 30369 146555 284012 156156 105321 54699 259924 286641 169420 258903 230704 130792 113508 246722 186298 39369 215243 278...
output:
202617
result:
ok single line: '202617'
Test #14:
score: 0
Accepted
time: 99ms
memory: 5824kb
input:
238328 31 68931 35852 6162 82105 43332 108964 154423 78529 96048 86087 53251 83427 63978 98391 136952 67533 30439 14955 125381 16926 92168 109294 134091 84295 79088 35162 25305 48674 43120 107419 137268 135695 143261 12055 86401 55234 120988 85826 2358 85648 16893 79259 37720 104500 22590 19616 1696...
output:
27396
result:
ok single line: '27396'
Test #15:
score: 0
Accepted
time: 153ms
memory: 4764kb
input:
131383 137 126024 5380 548554 309937 186045 571694 647219 672060 103626 290693 202435 470849 189046 614184 379735 272201 164579 92898 507493 665780 656670 576375 15656 655160 603111 595283 664367 444724 104477 390687 181193 334848 395980 44547 644873 1300 35674 26326 92838 243754 421429 295152 29544...
output:
17222
result:
ok single line: '17222'
Test #16:
score: 0
Accepted
time: 104ms
memory: 4904kb
input:
148877 53 129525 167747 56171 4683 107792 197450 250893 257183 77550 108798 75341 188253 29643 76236 57609 135433 205551 68034 216796 131181 69810 241189 46665 18252 107524 181882 154723 241921 250923 212890 192464 115356 156011 248671 160463 39152 221456 146228 31228 33921 255034 146995 262662 6009...
output:
147273
result:
ok single line: '147273'
Test #17:
score: 0
Accepted
time: 97ms
memory: 4328kb
input:
77618 197 968830 808569 499149 599530 864620 897164 611278 320720 176058 147073 358317 102157 46192 21093 237561 287882 692338 245506 292616 422899 526067 945777 897668 429527 14623 454655 948220 463083 124124 816138 337590 107756 789733 836547 857602 668944 898734 483605 154905 89571 630580 663406 ...
output:
38637
result:
ok single line: '38637'
Test #18:
score: 0
Accepted
time: 22ms
memory: 4184kb
input:
50653 37 128169 164517 100434 147134 81318 140360 119101 76930 12897 40735 124741 241 154040 113849 44349 4289 119652 130262 136592 48199 94044 62684 116222 126023 43004 179015 170217 140290 5072 52696 132433 133237 32153 76055 123562 141695 59607 57610 61823 72495 126574 1548 100995 95551 143612 17...
output:
48359
result:
ok single line: '48359'
Test #19:
score: 0
Accepted
time: 50ms
memory: 4544kb
input:
106097 79 57951 115622 153022 150686 134361 238521 326170 118961 323043 311096 74703 342902 149911 327235 8962 32302 118499 34949 172993 129162 82491 39513 335785 293965 264534 227931 212356 334433 291463 73123 142868 349434 248943 356072 165312 383289 199503 96339 107098 127581 72588 242101 135633 ...
output:
5145
result:
ok single line: '5145'
Test #20:
score: 0
Accepted
time: 112ms
memory: 4984kb
input:
172225 83 301973 302113 328781 351989 224625 328559 299072 157442 195249 336808 75227 186958 232346 263105 118001 351397 53559 375781 259165 246024 289061 135334 236385 252098 27399 273375 139023 408220 39358 232042 296578 341359 182321 273587 278228 55169 250484 162261 212608 30620 147217 287788 21...
output:
6745
result:
ok single line: '6745'