QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#710037#8758. Menji 和 gcdszy10010AC ✓29ms3720kbC++231.4kb2024-11-04 18:11:372024-11-04 18:11:46

Judging History

This is the latest submission verdict.

  • [2024-11-04 18:11:46]
  • Judged
  • Verdict: AC
  • Time: 29ms
  • Memory: 3720kb
  • [2024-11-04 18:11:37]
  • Submitted

answer

#include <map>
#include <set>
#include <queue>
#include <deque>
#include <cmath>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define fi first
#define se second
#define u1 (u<<1)
#define u2 (u<<1|1)
#define pb emplace_back
#define pp pop_back()
#define int long long
#define laile cout<<"laile"<<endl
#define lowbit(x) ((x)&(-x))
#define double long double
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld %lld",&x,&y)
#define sd(x) scanf("%Lf",&x)
#define sdd(x,y) scanf("%Lf %Lf",&x,&y)
#define _for(i,n) for(int i=0;i<(n);++i)
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
#define _pre(i,a,b) for(int i=(a);i>=(b);--i)
#define all(x) (x).begin(), (x).end()
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef unsigned long long ULL;
typedef pair<int,int>PII;
typedef pair<double,double>PDD;
const int N=1e6+10,INF=4e18;
int n,m;
void solve()
{
	int l,r;
	cin>>l>>r;
	int res=1;
	for(int g=1;g<=1000000;g++)
	{
		int k=r/g;
		if((k-1)*g>=l)res=max(res,g);//cout<<"g="<<g<<endl;
		k=g;
		int nowg=r/k;
		if((k-1)*nowg>=l)res=max(res,nowg);
//			if((k+1)*nowg<=r)res=max(res,nowg);//cout<<"nowg"<<nowg<<" "<<(k+1)<<" "<<nowg<<endl;
//		}
	}
	cout<<res<<'\n';
	return ;
}
signed main()
{
	IOS;
	int T=1;
    cin>>T;
	while(T--)
		solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 29ms
memory: 3664kb

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: 18ms
memory: 3708kb

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: 21ms
memory: 3596kb

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: 24ms
memory: 3664kb

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: 26ms
memory: 3596kb

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: 29ms
memory: 3588kb

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: 29ms
memory: 3588kb

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: 29ms
memory: 3588kb

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: 26ms
memory: 3640kb

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: 29ms
memory: 3652kb

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: 29ms
memory: 3664kb

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: 29ms
memory: 3664kb

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: 29ms
memory: 3652kb

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: 29ms
memory: 3716kb

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: 29ms
memory: 3628kb

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: 29ms
memory: 3596kb

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: 0
Accepted
time: 26ms
memory: 3580kb

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
5158908
4875888
189245382
113649989
117948283
109176137
137011862
32883384

result:

ok 10 numbers

Test #18:

score: 0
Accepted
time: 29ms
memory: 3596kb

input:

10
712493232457 949930998123
237436852451 474965499060
237453044594 474965499064
712357679580 949930998124
237442339950 474965499059
474987738852 712448248595
712450652059 949930998117
237524662803 474965499062
474982316829 712448248596
475023630122 712448248589

output:

189986199624
237482749530
237482749532
237482749531
237482749529
178112062148
189986199623
158321833020
178112062149
178112062147

result:

ok 10 numbers

Test #19:

score: 0
Accepted
time: 29ms
memory: 3648kb

input:

10
572610075962 687084687181
343472576068 458056458122
572614994634 687084687176
572511224603 687084687183
343520401814 458056458124
686986130467 801598801710
572656348261 687084687175
458117965994 572570572651
687174172945 801598801705
114492557922 229028229063

output:

98154955311
114514114530
98154955310
114514114530
114514114531
114514114530
98154955310
95428428775
100199850213
114514114531

result:

ok 10 numbers

Test #20:

score: 0
Accepted
time: 29ms
memory: 3596kb

input:

10
335051226484 418713243093
251302078020 334970594476
837526426397 921169134795
251221660169 334970594471
251327136882 334970594474
167511379594 251227945852
335001077836 418713243092
669843892294 753683837554
334877202410 418713243087
669946146564 753683837554

output:

69785540515
66994118895
76764094566
83742648617
66994118894
62806986463
69785540515
83742648617
83742648617
75368383755

result:

ok 10 numbers

Test #21:

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

input:

10
974440110429 998876825857
462965009805 487256988227
146099369012 170539945884
48652791617 73088548234
950134179627 974513976447
219168008747 243628494110
389842692961 414168439991
730846605766 755248331748
876987126032 901425428215
706493669423 730885482334

output:

24362849411
23202713725
24362849412
24362849411
24362849411
24362849411
23009357777
24362849411
24362849411
24362849411

result:

ok 10 numbers

Test #22:

score: 0
Accepted
time: 26ms
memory: 3720kb

input:

10
543985862023 621791593736
621864461476 699515542955
310951473615 388619746086
621700541423 699515542953
777209197312 854963441395
388662450147 466343695302
854910038538 932687390605
466382370502 544067644524
544049241638 621791593739
77664980475 155447898436

output:

77723949217
69951554295
64769957681
77723949217
77723949217
66620527900
77723949217
68008455565
77723949217
77723949218

result:

ok 10 numbers

Test #23:

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

input:

10
560046433646 570125403249
640231314951 650143003708
360132951208 370081402115
210122658309 220048401263
410082494929 420092402403
240078101011 250055001428
350042026036 360079202053
40032125451 50011000294
540148431802 550121003141
780145135458 790173804512

output:

10002200057
9850651571
9738984266
9567321794
10002200057
9617500054
10002200057
8335166715
9823589341
10002200057

result:

ok 10 numbers

Test #24:

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

input:

10
10069925101 20018404217
600629119936 610561328527
150133556468 160147233716
430326828513 440404892717
440392267179 450414094822
430369945550 440404892710
39965270060 50046010544
130214362423 140128829502
600622028114 610561328536
960809594312 970892604379

output:

6672801405
9847763363
10009202107
10009202107
10009202107
10009202107
10009202108
9341921966
9847763363
10009202107

result:

ok 10 numbers

Test #25:

score: 0
Accepted
time: 29ms
memory: 3592kb

input:

10
240101948920 320190016272
240065048463 320190016269
720361930807 800475040679
640435858456 720427536608
480261951214 560332528472
640359482709 720427536609
240052086688 320190016269
480369885567 560332528476
240104758318 320190016276
160097289385 240142512202

output:

80047504068
80047504067
80047504067
72042753660
80047504067
80047504067
80047504067
70041566059
80047504069
60035628050

result:

ok 10 numbers

Test #26:

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

input:

10
1 1000000000000
1 1000000000000
1 1000000000000
1 1000000000000
1 1000000000000
1 1000000000000
1 1000000000000
1 1000000000000
1 1000000000000
1 1000000000000

output:

500000000000
500000000000
500000000000
500000000000
500000000000
500000000000
500000000000
500000000000
500000000000
500000000000

result:

ok 10 numbers

Test #27:

score: 0
Accepted
time: 29ms
memory: 3584kb

input:

10
999999999999 1000000000000
999999999999 1000000000000
999999999999 1000000000000
999999999999 1000000000000
999999999999 1000000000000
999999999999 1000000000000
999999999999 1000000000000
999999999999 1000000000000
999999999999 1000000000000
999999999999 1000000000000

output:

1
1
1
1
1
1
1
1
1
1

result:

ok 10 numbers

Test #28:

score: 0
Accepted
time: 29ms
memory: 3588kb

input:

10
999999000000 1000000000000
999999000000 1000000000000
999999000000 1000000000000
999999000000 1000000000000
999999000000 1000000000000
999999000000 1000000000000
999999000000 1000000000000
999999000000 1000000000000
999999000000 1000000000000
999999000000 1000000000000

output:

1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000

result:

ok 10 numbers