QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#438659#8785. Fake Coin and Lying Scalesucup-team1198AC ✓272ms3992kbC++141.2kb2024-06-10 21:31:022024-06-10 21:31:03

Judging History

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

  • [2024-06-10 21:31:03]
  • 评测
  • 测评结果:AC
  • 用时:272ms
  • 内存:3992kb
  • [2024-06-10 21:31:02]
  • 提交

answer

#include <map>
#include <set>
#include <array>
#include <cmath>
#include <deque>
#include <bitset>
#include <random>
#include <string>
#include <vector>
#include <cassert>
#include <complex>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>

using namespace std;


using ld = long double;

const ld PI = atan2l(0, -1);

ld D(ld a, ld p) {
    cerr << a << " " << p << endl;
    return a * logl(a / p) + (1 - a) * logl((1 - a) / (1 - p));
}

ld F(int n, ld p, int k) {
    if (k == n + 1) {
        return -1e18;
    }
    if (k == n) {
        return logl(p) * n;
    }
    if (k == 0) {
        return 0;
    }
    return -n * D((ld)k / n, p);
}

void solve() {
    int n, k;
    cin >> n >> k;
    ld ans = logl(3ll * k + 1);
    k = min(k, n);
    if (3ll * k <= 2ll * n) {
        ans -= F(n, (ld)1 / 3, n - k);
    } else {
        ld p = F(n, (ld)2 / 3, k + 1);
        p = logl(1 - expl(p));
        ans -= p;
    }
    cout << ans << "\n";
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  cout << fixed << setprecision(20);

  int tst;
  cin >> tst;
  while (tst--) {
    solve();
  }


  return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3892kb

input:

2
100 0
100 1

output:

109.86122886681096913475
104.95422261188618041211

result:

ok q=0 (2 test cases)

Test #2:

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

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:

18.49866704752189240993
5.68697535633981982517
5.14843382199484994079
5.35185813347606649569
22.43766770764450627605
5.49716822529320186782
30.31238466473466224189
14.98217518706975156292
5.33753807970131797372
23.60797034397608865075
5.27408668160230788757
4.95582705760126073077
5.61312810638807022...

result:

ok q=0 (10000 test cases)

Test #3:

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

input:

1
10000 0

output:

10986.12288668109691336383

result:

ok q=0 (1 test case)

Test #4:

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

input:

1
10000 10

output:

10903.55285095766173419918

result:

ok q=0 (1 test case)

Test #5:

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

input:

1
10000 100

output:

10362.49993534137785466953

result:

ok q=0 (1 test case)

Test #6:

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

input:

1
100000 0

output:

109861.22886681096913719102

result:

ok q=0 (1 test case)

Test #7:

score: 0
Accepted
time: 3ms
memory: 3952kb

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:

774.90418335036883840106
855.46308795571809252545
799.65442389116527543980
85.10494796525128692599
522.85480877586085279862
838.03615617885252886410
641.73088357716064261682
702.54981125771018579673
504.95234960220237230288
125.46096334959558207811
260.18276659870588540802
724.50275352569917175494
1...

result:

ok q=0 (1000 test cases)

Test #8:

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

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:

7.74022952476318154818
7.23921497377980570050
6.36818718635049237824
6.79009723551390457835
7.32580750259577285610
7.34923082461333450907
6.56807791141197576650
7.45529848568329050118
7.62851762657505572682
6.02102334934952638981
7.59287028784481810234
7.32974968904151199817
7.86748856869912884665
6...

result:

ok q=0 (1000 test cases)

Test #9:

score: 0
Accepted
time: 164ms
memory: 3952kb

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.84144254303920718030
14.72666291095200514095
14.27737742334962741178
14.88820622691749827066
14.10850623816470520398
14.52645001308146419268
353449.38162521003141591791
96652.96887281786953849405
14.72074721808731864910
7079.80906490584263535126
14.63703820035290071450
60913.95907258638155212...

result:

ok q=0 (100000 test cases)

Test #10:

score: 0
Accepted
time: 191ms
memory: 3808kb

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.08664255734794323871
988099.58604373217553984432
579944.63940971744642638441
747481.93943193131570978949
820104.27891603714863322239
142602.54219834469343197725
1054345.42015993232075743435
504926.66077126173146893962
342762.78640099858159828727
451816.18863003649229881376
584219.161408615751...

result:

ok q=0 (100000 test cases)

Test #11:

score: 0
Accepted
time: 95ms
memory: 3712kb

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.52414303591172572549
14.44748368454757480803
14.46678102131282106935
14.88717328070450706193
14.69063465260236203431
14.84380910317801655247
12.48387860937424756469
14.78674543176452937064
14.65698463585982175544
14.25434918947683700288
14.28923475729737893256
13.26944282920997605912
14.632170107...

result:

ok q=0 (100000 test cases)

Test #12:

score: 0
Accepted
time: 176ms
memory: 3880kb

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.38897218724784448501
297865537.26650873132166452706
21.20893407370613261906
405381372.45130847048130817711
777499085.83816583984298631549
257440430.52094991542981006205
21.43647154343023830854
105964400.03699874664016533643
21.51422477529918605814
20.96361519575657466133
445375771.457178562297485...

result:

ok q=0 (100000 test cases)

Test #13:

score: 0
Accepted
time: 224ms
memory: 3896kb

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.56284453294938430190
993406414.42884520121151581407
513220007.41998039919417351484
22380597.88943771312369790394
247854657.52248853124910965562
602319066.05973473412450402975
127217805.64469091953651513904
659736898.96701817889697849751
503607554.54349924036068841815
550220064.56501298153...

result:

ok q=0 (100000 test cases)

Test #14:

score: 0
Accepted
time: 94ms
memory: 3920kb

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.67465820405449423817
21.30179560086173505724
20.69457507411962012348
21.19242787277673460179
21.80725219761950937902
20.90751165948626908407
21.24803351422751279340
21.60211129965743019794
21.45323700214522244165
18.58657125577329010356
19.38408110106205130101
21.80736015638240276812
21.450114682...

result:

ok q=0 (100000 test cases)

Test #15:

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

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.81191173707909554229
20.88531493228940306116
20.92625967545723474073
21.71937253337443966827
21.02415694963822570887
18.63680921099919882838
19.61209724176822806994
21.46712522099328735933
19.82094748514536471096
21.50442778264202503199
21.08959176575065294114
19.28092600666911151687
21.333491409...

result:

ok q=0 (100000 test cases)

Test #16:

score: 0
Accepted
time: 97ms
memory: 3808kb

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.02850620651732817257
21.60986506163010957560
21.38377393323840540244
21.70437545740151239447
21.44877629953504560682
20.35904413199340914388
20.61123479046185795124
20.09952402705059899823
21.28063906536671420072
20.34441888053407623826
21.37644596419053131565
20.71912542224711330403
21.552940195...

result:

ok q=0 (100000 test cases)

Test #17:

score: 0
Accepted
time: 231ms
memory: 3952kb

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.51785892529005650431
79945797.91502647702145623043
896551030.71452185552334412932
539706994.10596112080384045839
695323391.41855814098380506039
42420657.48851447684501181357
877659776.46090793854091316462
650860080.94060302135767415166
949986381.22732003644341602921
80819157.271811007092765...

result:

ok q=0 (100000 test cases)

Test #18:

score: 0
Accepted
time: 243ms
memory: 3928kb

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.60101553601271007210
953967301.80702868639491498470
89961609.82275211540400050581
243021906.17231770117359701544
231734295.47712836941354908049
779838665.46198566100792959332
344087276.60034042576444335282
313062769.01927259177318774164
1056036263.15229512489167973399
778672740.67652024893...

result:

ok q=0 (100000 test cases)

Test #19:

score: 0
Accepted
time: 191ms
memory: 3956kb

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.72494747879682108760
796226810.43071457615587860346
791081843.36806076660286635160
698496392.20105209812754765153
211203939.21836849383544176817
264138071.57049523362366016954
977355961.17935466166818514466
1060226376.36529891949612647295
712391726.36496225965674966574
724786.0161834988683...

result:

ok q=0 (100000 test cases)

Test #20:

score: 0
Accepted
time: 272ms
memory: 3712kb

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.93210032285423949361
333276396.94993082794826477766
321783878.27907862229039892554
57835238.01895331171908765100
969769144.50300416612299159169
454690067.62092909534112550318
338523075.48500360912294127047
350856623.34602302065468393266
104498321.33890990134386811405
220643276.89628146545...

result:

ok q=0 (100000 test cases)

Test #21:

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

input:

1
1000 1000000000

output:

21.82187812594785418160

result:

ok q=0 (1 test case)

Test #22:

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

input:

1
1 100000000

output:

19.51929303595380849230

result:

ok q=0 (1 test case)

Test #23:

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

input:

1
100 1000000000

output:

21.82187812594785418160

result:

ok q=0 (1 test case)

Test #24:

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

input:

1
1 1000000000

output:

21.82187812594785418160

result:

ok q=0 (1 test case)

Test #25:

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

input:

1
1000000000 1000000000

output:

21.82187812594785418160

result:

ok q=0 (1 test case)

Extra Test:

score: 0
Extra Test Passed