QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#442812#8785. Fake Coin and Lying Scaleszhangmj2008AC ✓71ms4220kbC++171.2kb2024-06-15 13:33:222024-06-15 13:33:24

Judging History

你现在查看的是最新测评结果

  • [2024-06-15 13:33:24]
  • 评测
  • 测评结果:AC
  • 用时:71ms
  • 内存:4220kb
  • [2024-06-15 13:33:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using uint = unsigned int; using i64 = long long; using ui64 = unsigned long long; using i128 = __int128;
const int INF = 1e9; const i64 LLNF = 4e18;

template< class Tp > void chkmax( Tp &x, Tp y ) { x = max( x, y ); }
template< class Tp > void chkmin( Tp &x, Tp y ) { x = min( x, y ); }

using ld = double;

constexpr int B = 100; vector< ld > fact;
void prework( ) { fact = vector< ld >( B + 1 ); fact[1] = 0; for( int i = 2; i <= B; i ++ ) fact[i] = fact[i - 1] + log( i ); }
ld factorial( int n ) { if( n <= B ) return fact[n]; else return n * log( n ) - n; }
ld binom( int n, int m ) { if( m < 0 || m > n ) return -INFINITY; else return factorial( n ) - factorial( m ) - factorial( n - m ); }

// Phi( n, m ) = log( sum( binom( n, k ) * 2 ^ k: 0 <= k <= m ) )
ld Phi( int n, int m ) { int k = min( m, 2 * n / 3 ); return binom( n, k ) + log( 2 ) * k; }

void solve( ) {
	int n, m; cin >> n >> m;
	cout << fixed << setprecision( 10 ) << log( 3ll * m + 1 ) + n * log( 3 ) - Phi( n, m ) << "\n";
}

int main( ) {
	ios::sync_with_stdio( 0 ), cin.tie( 0 ), cout.tie( 0 );
	prework( ); int T; cin >> T; while( T -- ) solve( ); return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 4072kb

input:

2
100 0
100 1

output:

109.8612288668
105.9492058614

result:

ok q=0 (2 test cases)

Test #2:

score: 0
Accepted
time: 4ms
memory: 4048kb

input:

10000
32 6
45 98
67 57
35 70
29 3
22 81
59 12
48 16
63 69
99 36
60 36
32 47
73 91
81 30
7 7
71 57
38 60
35 19
92 40
3 17
21 71
54 62
95 67
60 50
10 20
19 80
64 73
10 21
70 97
84 3
26 22
38 47
37 38
31 91
11 37
73 17
75 98
8 74
73 60
87 10
94 48
35 73
18 14
88 25
61 54
39 59
100 90
70 98
73 21
92 11
...

output:

20.2241426501
7.7636870232
7.4430544761
7.3186175437
23.8793221858
7.2872207818
32.3673850489
17.0907511792
7.5806345812
26.0954715321
7.5310372187
6.8798167915
7.9494403805
21.7042949648
4.4533916903
7.4567780786
7.2046549482
7.2176453729
17.6384221947
4.7621739348
7.0690171945
7.3979011918
7.76037...

result:

ok q=0 (10000 test cases)

Test #3:

score: 0
Accepted
time: 0ms
memory: 4148kb

input:

1
10000 0

output:

10986.1228866811

result:

ok q=0 (1 test case)

Test #4:

score: 0
Accepted
time: 0ms
memory: 3944kb

input:

1
10000 10

output:

10905.6314126008

result:

ok q=0 (1 test case)

Test #5:

score: 0
Accepted
time: 0ms
memory: 4116kb

input:

1
10000 100

output:

10365.7222922981

result:

ok q=0 (1 test case)

Test #6:

score: 0
Accepted
time: 0ms
memory: 4040kb

input:

1
100000 0

output:

109861.2288668110

result:

ok q=0 (1 test case)

Test #7:

score: 0
Accepted
time: 1ms
memory: 4068kb

input:

1000
867 38
906 28
876 34
182 38
692 59
986 55
675 20
699 12
741 82
154 11
264 6
682 4
176 19
728 69
37 95
501 56
998 96
495 52
359 86
750 19
726 39
794 6
268 16
609 70
414 45
182 19
123 68
909 56
880 71
419 8
679 14
363 16
751 35
299 73
852 35
901 36
903 63
425 85
416 33
80 89
863 91
491 32
603 84
...

output:

777.6441078953
858.0511048080
802.3389935964
87.8448725102
525.8139284469
840.9602764395
644.1518545668
704.7181459559
508.0756640142
127.5864231947
262.0114609953
726.1356299116
126.4117018857
532.1383232451
7.6753949545
344.1946092859
722.7392958450
349.3818272685
145.8419934306
728.6510814475
626...

result:

ok q=0 (1000 test cases)

Test #8:

score: 0
Accepted
time: 1ms
memory: 4100kb

input:

1000
71 766
31 464
8 194
12 296
69 506
55 518
31 237
73 576
50 685
1 137
29 661
58 508
46 870
33 172
66 94
41 634
38 725
94 163
94 45
34 685
71 486
95 511
37 108
54 643
64 94
1 624
48 283
1 64
23 122
3 866
52 798
68 669
43 460
68 187
50 403
31 877
100 191
44 512
33 50
91 732
37 584
22 501
46 93
81 7...

output:

10.0495131265
9.1789530646
7.6659979022
8.2237094925
9.6139873946
9.5517414821
8.5078160022
9.7916107598
9.7670486174
7.1196356380
9.4700880217
9.5571932282
9.9867598499
8.1720326084
7.9115930117
9.5938648559
9.6914015250
8.6517944810
14.4190825016
9.6096657743
9.5947901503
9.7877460147
7.8032283261...

result:

ok q=0 (1000 test cases)

Test #9:

score: 0
Accepted
time: 60ms
memory: 4172kb

input:

100000
448906 73251
858780 829062
380117 529011
219451 974416
390411 446812
457769 678634
440286 29979
663948 267273
623318 824172
557346 329036
2366 757990
279231 95725
394222 75586
671713 417299
997686 156089
462641 704003
267172 15563
115033 76151
271539 36507
909436 341831
97232 987703
780566 75...

output:

242693.8414425428
14.7266629100
14.2773780806
14.8882107837
14.1085062383
14.5264505592
353449.3816252095
96652.9688728172
14.7207476193
7079.8090649057
14.6371438565
60913.9590725856
188049.7517171232
3068.0010060286
555156.4425323715
14.5631511994
223395.5380747811
17.9804107752
165833.0679556715
...

result:

ok q=0 (100000 test cases)

Test #10:

score: 0
Accepted
time: 62ms
memory: 4048kb

input:

100000
740599 913
947030 8115
575926 9039
721122 7094
794424 8453
157723 6263
973352 1890
462079 302
333631 3870
435636 4238
572643 7448
775859 6119
343386 2778
486927 1883
880553 7918
878758 5150
274829 778
759586 5734
461205 6806
744940 1346
378522 4830
214767 1511
367452 9987
288068 9685
761467 1...

output:

805978.0866425572
988099.5860437318
579944.6394097178
747481.9394319318
820104.2789160373
142602.5421983445
1054345.4201599315
504926.6607712599
342762.7864009985
451816.1886300367
584219.1614086165
812410.1762793714
359182.8418828659
521307.5428221995
916720.8335910529
930250.9043964607
296057.4418...

result:

ok q=0 (100000 test cases)

Test #11:

score: 0
Accepted
time: 50ms
memory: 4220kb

input:

100000
3460 249080
4870 627106
7714 639325
6245 973410
5156 799724
2143 932101
3190 88015
5691 880401
4405 773261
157 516968
1022 535321
7679 193074
2293 754309
6302 607322
9422 65236
7327 352879
2188 417324
3181 532778
8804 165866
2433 321295
4829 557456
7228 613548
470 947610
2867 326654
1091 7711...

output:

13.5244320254
14.4476890093
14.4669106501
14.8872133117
14.6906831382
14.8442756662
12.4841920563
14.7867454318
14.6572116334
17.1663620198
14.2894793358
13.2694753848
14.6326061545
14.4154669136
12.1844106743
13.8726302095
14.0406882337
14.2847873540
13.1175782064
13.7787283093
14.3298035108
14.425...

result:

ok q=0 (100000 test cases)

Test #12:

score: 0
Accepted
time: 57ms
memory: 4016kb

input:

100000
485911443 648621499
967545108 273118575
544774196 541753568
572826636 56596285
997351031 75012282
841305005 238445153
871651103 680174033
831928615 349267999
895576242 735170120
38669405 423897783
879163052 156607422
474161410 146955978
703868457 884260985
882781563 482183053
774752914 414027...

output:

21.3889722824
297865537.2665129900
21.2089335918
405381372.4513075948
777499085.8381696939
257440430.5209509134
21.4364715815
105964400.0369997025
21.5142275095
20.9636152536
445375771.4571757317
125531063.0115738511
21.6988730431
27488627.5314886570
28988557.8559976816
21.1228002310
20.9327567220
2...

result:

ok q=0 (100000 test cases)

Test #13:

score: 0
Accepted
time: 62ms
memory: 4124kb

input:

100000
998709247 6662353
938409567 5496364
470262254 388552
44631553 8053900
263812189 8140673
570847244 3686835
143527865 6364614
630983298 5151426
508843717 9845212
529080317 4866307
229185417 7424168
870671276 2477533
922155225 4868463
286532330 7131107
5469824 6272182
112064124 9288326
871839242...

output:

1052557867.5628446341
993406414.4288468361
513220007.4199798107
22380597.8894377574
247854657.5224891007
602319066.0597361326
127217805.6446906924
659736898.9670209885
503607554.5434994698
550220064.5650136471
213873948.7807152867
937815577.9327400923
979331023.4859906435
276465502.7357553244
16.750...

result:

ok q=0 (100000 test cases)

Test #14:

score: 0
Accepted
time: 57ms
memory: 4124kb

input:

100000
2388237 863104141
1949853 594471487
5788570 323905636
6626472 532884672
6478027 985480511
8713369 400770447
7877963 563355387
8572690 802705946
246447 691673591
1048191 39348128
9822372 87353076
4622806 985586908
3940664 689517333
7206000 907183324
7647553 126209541
9304319 816108273
3026286 ...

output:

21.6746582021
21.3017956042
20.6945752315
21.1924278876
21.8072523493
20.9075117689
21.2480335385
21.6021114346
21.4532370025
18.5865712562
19.3840810861
21.8073603678
21.4501147438
21.7244674042
19.7520665433
21.6186699122
21.2367298868
20.8567963141
21.4600164611
21.2233530469
20.9539225507
21.317...

result:

ok q=0 (100000 test cases)

Test #15:

score: 0
Accepted
time: 46ms
memory: 4064kb

input:

100000
3230 990083111
447677 391972657
692146 408354973
191509 902573102
662501 450354073
721550 41375394
457751 109724688
636199 701346721
4329 135209393
7190 728002830
562092 480808431
608393 78791345
751611 613615532
576135 459945713
830181 180428675
549685 436319534
608642 828570290
40757 416064...

output:

21.8119891325
20.8853154909
20.9262611208
21.7193777550
21.0241573279
18.6368095578
19.6120977880
21.4671267939
19.8209474851
21.5044625523
21.0895917660
19.2809264179
21.3334914113
21.0452313141
20.1094583962
20.9924995180
21.6338249309
20.9449703760
20.8324908363
20.8845400285
21.5258320155
18.952...

result:

ok q=0 (100000 test cases)

Test #16:

score: 0
Accepted
time: 52ms
memory: 4156kb

input:

100000
25834 61214455
26648 808954129
93315 645258548
40846 889138139
50931 688595112
83574 231579050
4476 298005500
10230 178645104
67274 582026639
45478 228216795
31799 640547396
76931 331956048
42831 764190687
32200 938076217
11303 774768820
48548 908303551
52646 376587760
30951 91507236
32097 76...

output:

19.0285449147
21.6098744431
21.3837739333
21.7043999394
21.4487762996
20.3590441321
20.6112347905
20.0995240271
21.2806427816
20.3444408690
21.3764538260
20.7191286720
21.5529401955
21.7579851031
21.5667096528
21.7257066265
20.8452787106
19.4305409014
21.5479007997
21.4986984372
20.8226589781
20.181...

result:

ok q=0 (100000 test cases)

Test #17:

score: 0
Accepted
time: 71ms
memory: 4172kb

input:

100000
274227737 68346059
218685007 54356465
989024364 38654736
621112634 30460344
744276614 23921662
244777456 92571767
802238000 396401
867445410 73326922
915786289 8870270
283682509 84172313
874633287 75201041
511367562 84949073
634359016 56041772
732833967 55417420
693037815 93779223
439536157 2...

output:

99920311.5178580582
79945797.9150264263
896551030.7145178318
539706994.1059617996
695323391.4185571671
42420657.4885148406
877659776.4609080553
650860080.9406018257
949986381.2273209095
80819157.2718109488
652369963.8650002480
272959455.7458930016
468593082.5769343376
570331660.3127639294
421678366....

result:

ok q=0 (100000 test cases)

Test #18:

score: 0
Accepted
time: 69ms
memory: 4108kb

input:

100000
145675394 9644
868401983 5079
81959359 7252
221259510 4525
210940342 503
709938567 8322
313226886 2026
284975389 1034
961263243 1271
708878403 8424
147154537 1117
597142707 9049
49009960 8469
632841549 912
998250617 5932
107131683 9999
243110679 3650
921083825 3103
645636937 7805
803218474 41...

output:

159931657.6010158956
953967301.8070304394
89961609.8227521479
243021906.1723180711
231734295.4771282971
779838665.4619854689
344087276.6003411412
313062769.0192717910
1056036263.1522955894
778672740.6765197515
161650731.7002803683
655912585.9075793028
53755245.8843458891
695233699.7935427427
1096608...

result:

ok q=0 (100000 test cases)

Test #19:

score: 0
Accepted
time: 70ms
memory: 4172kb

input:

100000
415903859 143863
726725861 220923
721402153 142794
636365369 56467
195687608 492519
244711303 612418
892437244 320712
965738323 66085
653139241 592706
2885567 920921
430945805 947767
493265196 74615
877041778 105313
477250612 324587
932782139 573227
651591411 492931
438774413 597150
816745072...

output:

455527052.7249460220
796226810.4307137728
791081843.3680573702
698496392.2010533810
211203939.2183684111
264138071.5704949796
977355961.1793550253
1060226376.3653010130
712391726.3649631739
724786.0161835044
466038723.5735968351
541124541.7703812122
962399883.8266369104
521396645.7448273301
10195567...

result:

ok q=0 (100000 test cases)

Test #20:

score: 0
Accepted
time: 65ms
memory: 4104kb

input:

100000
932735028 38475
303723723 37217
293643065 82693
53306635 90174
883367937 63149
414476477 62827
308746443 66010
319864936 52981
95584375 56035
201651629 95614
453621071 58910
638222297 35431
980668234 47930
725614760 41170
688105374 50896
958291243 76312
808245100 31656
617265859 68228
8643946...

output:

1024260593.9321005344
333276396.9499306679
321783878.2790784836
57835238.0189534500
969769144.5030032396
454690067.6209294200
338523075.4850032330
350856623.3460218906
104498321.3389098346
220643276.8962815702
497726769.6263056397
700751697.8219574690
1076817268.4211857319
796697076.4445762634
75539...

result:

ok q=0 (100000 test cases)

Test #21:

score: 0
Accepted
time: 0ms
memory: 4136kb

input:

1
1000 1000000000

output:

21.8228777931

result:

ok q=0 (1 test case)

Test #22:

score: 0
Accepted
time: 0ms
memory: 4112kb

input:

1
1 100000000

output:

20.6179053246

result:

ok q=0 (1 test case)

Test #23:

score: 0
Accepted
time: 0ms
memory: 4036kb

input:

1
100 1000000000

output:

24.3090865570

result:

ok q=0 (1 test case)

Test #24:

score: 0
Accepted
time: 0ms
memory: 4044kb

input:

1
1 1000000000

output:

22.9204904146

result:

ok q=0 (1 test case)

Test #25:

score: 0
Accepted
time: 0ms
memory: 4104kb

input:

1
1000000000 1000000000

output:

21.8218781948

result:

ok q=0 (1 test case)

Extra Test:

score: 0
Extra Test Passed