QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#776751#8758. Menji 和 gcdabovecloud#WA 20ms3704kbC++141.7kb2024-11-23 20:47:432024-11-23 20:47:43

Judging History

This is the latest submission verdict.

  • [2024-11-23 20:47:43]
  • Judged
  • Verdict: WA
  • Time: 20ms
  • Memory: 3704kb
  • [2024-11-23 20:47:43]
  • Submitted

answer

/*** WORK : 省赛\2023gdcpc\G.cpp ***/
/*** TIME : 2024/11/23 18:55 ***/
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define pb push_back
#define se second
#define fi first
#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int MOD = (int) 1e9 + 7;
const int INF = INT_MAX;
// L*2 >= r
int gcd(int x,int y){
    return x%y==0 ? y:gcd(y,x%y);
}
void solve() {
    int L,R;
    cin >> L >> R;
    int g = gcd(L,R);
    int mx = 0;
    for(int i=1;i*i<=R;i++){
        if(L%i==0 && R%i==0){
            int a1 = i;
            L/=a1;R/=a1;
            int l=2,r=R,ans=0;
            while(l<=r){
                int mid = l + r >> 1;
                int t = R/mid;
                if(R/t*t - t >= L){
                  r = mid - 1;
                  ans = mid;
                }else{
                    l = mid + 1;
                }
            }
            mx = max(mx,(R/ans)*a1);
            L*=a1;R*=a1;
            // L/=a2;R/=a2;
            // l=2,r=R,ans=0;
            // while(l<=r){
            //     int mid = l + r >> 1;
            //     int t = R/mid;
            //     if(R/t*t - t >= L){
            //       r = mid - 1;
            //       ans = mid;
            //     }else{
            //         l = mid + 1;
            //     }
            // }
            // mx = max(ans,(R/ans)*a2);
            // L*=a2;R*=a2;
        }
    }
    cout << mx << endl;
    
}

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(12);
    int T = 1;
    cin>>T;
    while (T--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3632kb

input:

10
1 2
2 4
6 10
11 21
147 154
1470 1540
2890 3028
998244353 1000000007
34827364537 41029384775
147147147147 154154154154

output:

1
2
3
7
7
70
126
1754385
5861340682
7007007007

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 11ms
memory: 3696kb

input:

6
357134483534 646200407704
504479652692 514965927651
831245941727 837097365832
778543598197 990152196633
19580905336 99295489037
228262697783 935881261360

output:

215400135901
10299318553
5813176151
198030439326
49647744518
467940630680

result:

ok 6 numbers

Test #3:

score: 0
Accepted
time: 15ms
memory: 3572kb

input:

7
24156128688 371395282633
93351396074 399537014285
203744768858 207305338115
331358960274 541403932388
535326774637 847689479337
109669198404 854801965853
291136016500 612166835800

output:

185697641316
199768507142
3513649798
180467977462
282563159779
427400982926
306083417900

result:

ok 7 numbers

Test #4:

score: 0
Accepted
time: 18ms
memory: 3608kb

input:

8
708500395894 954976947804
185383756425 187715724160
336255480399 540420412130
208480512454 762084392595
22036300266 724322568277
280577240999 656905710919
103629116724 670519296271
78377014991 264809735144

output:

238744236951
2317478076
180140137376
381042196297
362161284138
328452855459
335259648135
132404867572

result:

ok 8 numbers

Test #5:

score: 0
Accepted
time: 20ms
memory: 3684kb

input:

9
606607046705 663435269111
715285576647 870424615771
185598415786 969306885465
134603019625 587909089942
289410174524 773994064362
64257501131 283827511580
2405725551 471676411984
248337846173 276044769374
74123922237 585563615802

output:

55286272425
145070769295
484653442732
293954544971
386997032181
141913755790
235838205992
27604476937
292781807901

result:

ok 9 numbers

Test #6:

score: 0
Accepted
time: 20ms
memory: 3624kb

input:

10
99162126073 426444661852
25906289876 995967541117
94357849619 525801764946
123961073689 999652598922
362732190354 514599165600
424491073677 514172139588
833244400349 877569320422
438204158967 823294623765
144662562418 386796486586
30123581892 537543794859

output:

213222330926
497983770558
262900882473
499826299461
128649791400
85695356598
43878466021
274431541255
193398243293
268771897429

result:

ok 10 numbers

Test #7:

score: 0
Accepted
time: 13ms
memory: 3576kb

input:

10
173459630570 278448404754
106931638608 117845428658
303809630229 520423172096
408794735346 740232633575
342372183120 478941899016
117467991420 179100556099
285438133107 305883132106
429002558020 535753405738
36762990062 37048871953
197653121865 316669461373

output:

92816134918
10713220787
173474390698
246744211191
119735474754
59700185366
20392208807
89292234289
284991322
105556487124

result:

ok 10 numbers

Test #8:

score: 0
Accepted
time: 16ms
memory: 3680kb

input:

10
108014216634 117529787626
264181836639 268854952446
383992860046 487264052466
243971240739 295824050589
68004850879 72418064474
332584671866 449474684144
483505388653 496876995931
154890401402 160756439229
389419796306 447929576482
120366346161 146285941685

output:

9040752894
4635430214
97452810493
49304008431
4259886145
112368671036
13075710419
5741301401
55991197060
24380990280

result:

ok 10 numbers

Test #9:

score: 0
Accepted
time: 14ms
memory: 3704kb

input:

10
342499685890 383499595096
273042083817 337081642883
280665038017 305632868905
270255567455 306246694067
88754512544 103478925574
394443812809 402341874650
489832456145 534233349017
16361625069 16387381221
24480406485 24849244086
86457983221 88141386003

output:

38349959509
56180273813
23510220685
34027410451
12934865696
7889056365
41094873001
25725873
365430060
1663045018

result:

ok 10 numbers

Test #10:

score: 0
Accepted
time: 14ms
memory: 3564kb

input:

10
169898123325 172486221147
353153887427 357663796473
228114969073 243524921639
238333055370 249216812472
134591443023 138425264627
284936035841 285818375942
77848599673 86832555127
255881247385 264207487850
438603942586 457841424689
6591825003 7139045710

output:

2574421211
4470797455
15220307602
10835513585
3741223368
882155481
8683255512
8256483995
19076726028
509931836

result:

ok 10 numbers

Test #11:

score: 0
Accepted
time: 16ms
memory: 3572kb

input:

10
457003612436 480976454252
350549088555 361425062735
252283910662 255403605285
424430937341 447033937743
346742321116 358718654210
480225836374 492522609553
175105243451 178510384862
10600043332 11002815528
275393124501 287691175977
407669127232 426148340893

output:

22903640678
10630148903
3114678113
22351696887
11957288473
12012746574
3368120469
392957697
11987132332
17756180870

result:

ok 10 numbers

Test #12:

score: 0
Accepted
time: 12ms
memory: 3624kb

input:

10
305562990967 313903469393
123853159101 127535918416
328293770786 332482946409
61442896276 62130677976
193946028079 199100836295
252915948606 253364032303
325194628379 329278719245
89555081247 89947462644
108893944188 110143916995
39347269365 39408581207

output:

8260617615
3643883383
4156036830
682754703
5105149648
447639633
4065169373
391075924
1237572101
61288617

result:

ok 10 numbers

Test #13:

score: 0
Accepted
time: 15ms
memory: 3700kb

input:

10
420242815429 423436989799
253060719300 255898086031
490354842465 493770449865
45725854960 46149292125
84411527311 85009065483
387718973264 393010125600
240815872646 242239053492
204045361125 207163055249
284296578204 288145806016
407403020698 409654411624

output:

3183736765
2812066879
3405313447
423388001
594468989
5240135008
1416602652
3091985899
3841944080
2250848415

result:

ok 10 numbers

Test #14:

score: 0
Accepted
time: 14ms
memory: 3640kb

input:

10
314861555121 316250756871
270980367077 271731993705
196488747864 196654040818
52645558757 52788958154
33790040339 33873091906
242994310605 243473136635
483917662242 485910930972
77944659142 78407610859
327488060604 328121345745
449162590705 450482530158

output:

1387064723
750640866
165255496
143059507
83022284
478336221
1991438241
461221240
632218392
1317200380

result:

ok 10 numbers

Test #15:

score: 0
Accepted
time: 11ms
memory: 3644kb

input:

10
179895353536 180256035313
413520891086 413910972866
382426622541 382916884425
294943763242 295616894905
247576947789 248310606048
304570762424 305341290222
279622509449 280065933924
176830308437 177169663832
121568116834 121742364013
34758817375 34861828544

output:

360512070
389746678
489663535
671856579
732479663
769121637
443142300
338756527
174166472
102837252

result:

ok 10 numbers

Test #16:

score: 0
Accepted
time: 16ms
memory: 3552kb

input:

10
351673086258 352137223724
114791916187 114942798757
279621296142 279887689142
98290804160 98411077259
192189341890 192344476109
273915105819 273981596318
485598059436 485921227640
466326136619 467023440750
206058441426 206194455461
494100101161 494566195341

output:

463948911
150843567
266306079
120160045
155116512
66484250
323085922
697049911
136012173
465693215

result:

ok 10 numbers

Test #17:

score: -100
Wrong Answer
time: 13ms
memory: 3684kb

input:

10
457437275529 457744246712
248867950493 248922255021
84255284287 84260444535
10741580135 10746457953
225958947556 226148232192
298785795630 298899472783
128209676494 128327732497
200119804622 200229036698
298685798405 298822872777
202397226668 202430117275

output:

306799092
54290568
5151968
4875888
189245382
113649989
117948283
109176137
137011862
32883384

result:

wrong answer 3rd numbers differ - expected: '5158908', found: '5151968'