QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#729680 | #9597. Grade 2 | yzhx# | WA | 251ms | 19652kb | C++20 | 1.1kb | 2024-11-09 17:36:46 | 2024-11-09 17:36:49 |
Judging History
answer
#include <iostream>
#include <math.h>
#include <vector>
#include <functional>
#include <stdlib.h>
using namespace std;
using ll = long long;
ll gcd(ll i , ll j){
return j == 0 ? i : gcd(j , i % j);
}
void slove(){
ll x , n;
cin >> x >> n;
ll range = 1 << 21;
// cout << range << endl;
vector<ll> pre(range);
pre[0] = 0;
for (ll i = 1 ; i < pre.size() ; i++){
pre[i] = pre[i - 1];
ll tmp = i * x;
tmp = (tmp + x) - (tmp ^ x);
if (gcd(tmp , x) == 1) pre[i]++;
}
function<ll(ll)> cal = [&](ll up){
ll ans = 0;
ans = (up / range) * pre.back();
ans += pre[up % range];
// 0 1 2 3 4 5
// 0 1 2 3
// cout << "up : " << up << " " << ans << endl;
return ans;
};
// cout << range << endl;
// cout << pre.back() << endl;
while(n--){
ll l , r;
cin >> l >> r;
ll res = cal(r) - cal(l - 1);
cout << res << "\n";
}
}
int main(){
// ios::sync_with_stdio(false);
// cin.tie(0);
// cout.tie(0);
slove();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 17ms
memory: 19532kb
input:
15 2 1 4 11 4514
output:
2 2252
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 232ms
memory: 19544kb
input:
500696 100000 110442401300 646889080214 337192 670162015551 508011001649 508011014425 94418501628 94418501634 824168677375 824168677376 732815842309 795402573302 353241304050 846773277757 622033633276 622033633284 760381702139 760381702143 207714 795408271057 382792 952061527685 686173 331215904334 ...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 100000 lines
Test #3:
score: 0
Accepted
time: 251ms
memory: 19556kb
input:
465262 100000 119442423888 249533375982 528365238401 528365275157 654839906300 654839906303 135820863700 135820967840 336231 918143221477 568175915485 568176067832 993015103483 993015103488 951474 444595379179 298623434750 298623434751 257961 410491919396 996297715292 996297994388 17765498878 177654...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 100000 lines
Test #4:
score: 0
Accepted
time: 206ms
memory: 19600kb
input:
599394 100000 683408 868635908987 347999512025 347999739145 740945 377178907084 399211757563 399211757568 766968 548821086083 630762 702128377806 756554924031 756554924036 904713771313 904714518208 17026878789 17027129255 11601638470 206412869961 253365321722 253365321730 785476956554 785477402085 2...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 100000 lines
Test #5:
score: 0
Accepted
time: 219ms
memory: 19464kb
input:
255255 100000 693776785134 693776920782 174578728959 174578728960 109045569231 631173362385 470661333171 470661439492 401883 183360880923 436203696728 436203931780 165055 339075075373 640081 299360395352 864237441330 864237509663 730335563579 730335652091 194265481215 194265481219 40664920117 406649...
output:
48406 1 186110004314 37959 65357983202 83815 120861662355 106705381500 24327 31556 2 13697 28081 260202193146 52511483770 4 46174459075 3 175347987986 2 47909 258154440479 327427357801 2 22468 54932 46381156133 45666301683 94552873123 55243 2 152254920558 2 109713294365 91231052949 144890963440 1 19...
result:
ok 100000 lines
Test #6:
score: 0
Accepted
time: 206ms
memory: 19652kb
input:
504735 100000 890566082557 890566082559 106681282682 350150954751 14542620333 14542688528 962703917051 962703917057 100450168807 730499846454 90869911943 879001649039 367411155928 367411237841 162790964603 162791319243 843464048636 843464048641 50183553762 50183754394 536413208571 536413208579 76470...
output:
3 91776653818 25745 4 237499194819 297088721196 30767 133683 4 75618 5 14803350036 102273946312 294367282076 90067 26374064222 218863908151 5920 116441 80585705578 78122672310 26247 4 2 362715381968 5 118998177006 1 46573605766 3 294440148616 16240766556 148286820503 170413778829 308538368031 80990 ...
result:
ok 100000 lines
Test #7:
score: 0
Accepted
time: 238ms
memory: 19568kb
input:
510510 100000 636202516477 636202516483 766250113730 766250554933 783526 196225463076 79706372523 706598274579 942892 658373730973 467824279548 467824279556 21452896555 313469857150 378837 377299671727 240905 332480727153 498636101528 498636124308 976243856348 976243893391 292392 796495578924 544557...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 100000 lines
Test #8:
score: 0
Accepted
time: 101ms
memory: 19492kb
input:
5 100000 577002044614 577002044615 927612729821 927612729823 458108524625 458108524631 280764605824 668589153220 952951869418 952951869419 529611 683061174939 139562629162 943958766161 682886119356 682886119359 809277569284 809277569288 273256 823615062996 553997 845861944424 810372 355828187260 560...
output:
2 3 4 193912273697 0 341530322664 402198068500 4 4 411807394869 422930695215 177913688445 0 0 4 3 384044390963 2 225492836247 123433323681 163157461936 325461532446 1 143731759371 302892329368 432434490591 3 4 380078319798 2 475791735460 2 0 175885810334 1 106930234833 0 248426664239 3 3 2 142058695...
result:
ok 100000 lines
Test #9:
score: 0
Accepted
time: 92ms
memory: 19616kb
input:
67 100000 554948711586 554948711636 107216748533 551267140383 563444278266 563444278271 296834528251 296834528257 945075901986 945075902057 820833 418403638528 42398724782 775548809425 136440466958 136440467007 137424666397 245095767595 293841341489 293841341519 389980376654 389980376662 65049866518...
output:
41 333037793887 6 5 52 313802113274 549862563484 36 80753325903 24 9 204510681731 473854242629 97253383657 475906911704 2 410453985059 65 592074124647 58 116232829554 3 26550484176 9 8 608544154442 4 596001232498 7 7 295977286700 37 206073186915 280442942335 42 4 546702626742 7689840672 25 206159337...
result:
ok 100000 lines
Test #10:
score: 0
Accepted
time: 124ms
memory: 19568kb
input:
647 100000 463906998888 479659267251 268847 751155874289 651417786367 651417786370 497555 155709224392 622915482618 622915482628 777631 838255026695 243048678285 883954678899 772196356537 967103315725 82204086763 82204087076 66104 324475714342 991803 866563791381 463633987995 958099429201 383184 307...
output:
14767751592 704208380099 2 145976931409 9 785863358495 600849375577 182725274236 296 304195920221 812402624603 463561351131 288610355562 129966561457 283627883934 147229474948 7 912956605545 1 4 571081297966 248 359551529842 583 6 743201235071 7 3 189759269108 432607129516 6 5 434423260186 275 25074...
result:
ok 100000 lines
Test #11:
score: 0
Accepted
time: 174ms
memory: 19536kb
input:
4889 100000 767055827601 767055829288 490893 294465817432 199109591038 199109591039 399822153968 880358292711 825864 747773295851 118874 331319816798 928131530748 928131530753 533475 556937288088 417423462211 417423463757 285188 108197134613 199505599366 261970387618 533517149327 533517151742 848403...
output:
1636 285263285082 2 465519384412 724404580300 320965957363 4 539532481036 1499 104815697882 60512763621 2338 366584431777 3 761707061319 835258241886 2 238377636719 1469 2 45526221069 8 7 4 7 782134351716 902323964729 4 4 265399465733 1 5214 6 3271 2823 789992986908 355206949764 1151 65083701660 112...
result:
ok 100000 lines
Test #12:
score: 0
Accepted
time: 179ms
memory: 19508kb
input:
71473 100000 656103964666 656103964671 498648624075 498648637229 390504315038 647137082392 570202 924129361870 280087103369 431002142325 298239920694 774852456682 706167805477 706167829997 18668 138509788321 253794 654841194475 552838823872 552838883299 593165270991 891051126522 792248 278481571911 ...
output:
6 13051 254627823863 916909035485 149736015217 472889000553 24331 137427662078 649724995836 58966 295558622282 276305148576 58150260531 8727462519 65958 34832 32273 1 374742818985 974579726797 703332411703 6 112493 2313 16964 280078382150 493585564078 5 876393142339 67113 51312803819 277929355688 5 ...
result:
ok 100000 lines
Test #13:
score: 0
Accepted
time: 231ms
memory: 19616kb
input:
947137 100000 939374 755248253137 224227105223 472382869959 92509901532 701330847277 221867943268 946309636964 736631 404594275091 520041 340554160109 970446602238 970446602242 160354561278 751516102516 64990740479 64990740479 188023308283 188023308288 981243156946 981243222322 223384960026 44150610...
output:
754509767562 247913425109 608226394050 723734231081 404198427581 340221068165 3 590584235039 1 5 65313 217908137513 162936 8 149195 475632034863 3 292614 125979 3309 523598 336729889389 3 718959183140 1 701322266556 648513042428 6 157001 6 4 891628987081 839203 245040 137154282443 199050435598 25288...
result:
ok 100000 lines
Test #14:
score: 0
Accepted
time: 226ms
memory: 19480kb
input:
999763 100000 871469416445 871469416451 66152 791908961867 777345764209 777346045153 269291 297435009460 669356 360116089360 421377007492 783648031951 636957491199 636957491202 786893578508 786894249495 492327403515 492327403523 679508 654247174373 555190 965731300993 726894 279530730056 39378256871...
output:
5 790362198664 280395 296853812946 359412069573 361563463880 2 669686 7 652968669672 963844552936 278984046121 391256570836 978790360056 373170 4 679003 232633722051 448204751658 289995000591 3 939539712284 122172522837 385970821243 52443 575552777171 54043795511 525802 217025558619 446523 778017 72...
result:
ok 100000 lines
Test #15:
score: -100
Wrong Answer
time: 115ms
memory: 19600kb
input:
1 100000 391128977208 391128977208 596942630965 596942630969 208018 606593799103 629194896599 629194896599 349835863178 349835863178 531106536425 776212608295 736525416802 736525416802 81923833591 317949656478 536473402655 552509399268 125131 497916267917 403831493758 403831493758 696952420329 69695...
output:
1 5 606593301840 1 1 245105954995 1 236025710342 16035988967 497915905363 1 10 5 220224829723 3 623652976331 9 648891011411 1 412548633363 412088144288 7 564864334041 1 1 257968873140 1 8 8 5 3 6 1 1 272014132222 151772703022 1 80372844676 1 1 2 299815046409 10 6 1 298043190316 1 1 854735742958 1 1 ...
result:
wrong answer 3rd lines differ - expected: '606593591086', found: '606593301840'