QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#235164#6423. FireworksYangmf#AC ✓292ms4072kbC++171.4kb2023-11-02 15:27:532023-11-02 15:27:54

Judging History

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

  • [2023-11-02 15:27:54]
  • 评测
  • 测评结果:AC
  • 用时:292ms
  • 内存:4072kb
  • [2023-11-02 15:27:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
#define ld long double
#define M(x) {x%=mod;if(x<0) x+=mod;}
#define error           \
    {                   \
        cout << "No\n"; \
        return;         \
    }
#define all(x) (x.begin(), x.end())
template <typename A, typename B>
bool smax(A &a, const B &b) { return a < b ? a = b, 1 : 0; }
template <typename A, typename B>
bool smin(A &a, const B &b) { return b < a ? a = b, 1 : 0; }

const int N = 1e6 + 10;
int a[N];
int n, m,k;
const int inf=1e18;
ld p;
ld eps = 1e-9;
bool eql(ld x, ld y) { return fabs(x - y) < eps; }
bool lt(ld x, ld y) { return !eql(x, y) && x < y; }
bool rt(ld x, ld y) { return !eql(x,y)&& x>y;}
ld calc(ld k){

    return 1.0*(m+n*k)/(1-pow(1-p,k));
}
void solve()
{
    int p1;
    cin>>n>>m>>p1;
    p = p1*1.0/10000;
    int l=1, r=1e9;
    while (l < r)
    {
        int lmid = l + (r - l) / 3;
        int rmid = r - (r - l) / 3;
        if (calc(lmid) >= calc(rmid))
            l = lmid + 1;
        else
            r = rmid - 1;
    }
    cout<<setprecision(12)<<calc(l)<<"\n";
}
signed main()
{
    // freopen("D://Desktop//VSCODE//input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
    {

        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1 1 5000
1 1 1
1 2 10000

output:

4
10141.5852891
3

result:

ok 3 numbers

Test #2:

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

input:

20
10 27 2855
79 59 6888
65 72 7725
78 50 2888
31 21 5759
41 58 6619
47 27 3881
35 55 5095
77 7 6028
17 89 1792
84 60 8604
58 44 4923
88 27 3824
54 63 1482
19 42 5366
93 76 97
100 99 8660
96 36 4343
90 56 9515
24 44 9922

output:

89.7298056505
200.348432056
177.346278317
416.8398778
90.2934537246
149.569421363
190.672507086
164.601521116
139.349701393
275.133110248
167.364016736
207.190737355
300.732217573
589.058848951
101.877028212
10796.8872669
229.792147806
303.937370481
153.441933789
68.5345696432

result:

ok 20 numbers

Test #3:

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

input:

10
954269343 987322500 9806
916720797 981711601 9728
902477101 957414437 9250
967013471 988735825 9674
985383693 926528961 9411
970653208 917703218 9331
998423148 911924940 9283
986159007 902133513 9759
953796828 947934512 9959
995334734 931874197 9944

output:

1980003919.03
1951513567.02
2010693554.59
2021655257.39
2031572260.12
2023744964.1
2057899480.77
1934924193.05
1909560538.21
1938062078.64

result:

ok 10 numbers

Test #4:

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

input:

10
933722894 72 9673
975866948 5 9424
910984544 95 9682
994597175 6 9351
972675086 51 9712
952759975 51 9114
956482031 85 9478
921988922 72 9017
950640658 36 9893
965297247 78 9342

output:

965287879.665
1035512471.35
940905431.729
1063626543.69
1001518880.77
1045380761.47
1009160282.76
1022500825.11
960922565.45
1033287652.54

result:

ok 10 numbers

Test #5:

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

input:

10
910088095 81 316
970640211 35 537
908853334 41 89
932269507 8 457
953224740 22 113
959834859 69 34
924852390 63 115
952730384 97 382
917634328 91 20
937287266 32 654

output:

28800258734.2
18075237355.7
102118356742
20399770568.9
84356173628.3
282304390588
80421952434.8
24940588507.9
458817209500
14331610061.2

result:

ok 10 numbers

Test #6:

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

input:

10
968675373 962412132 104
923494255 934310785 381
922721350 957856460 282
978335370 917228676 825
951116860 942542480 359
999013758 972493824 676
930242700 964474169 342
968944030 984608304 520
965837594 909045242 369
990484700 925952624 479

output:

106669104052
31076848077.8
40771434362.9
16579259543.4
33660076568.7
20209258011.5
34581380127.4
24798113234.3
33145494087.7
26925682159.1

result:

ok 10 numbers

Test #7:

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

input:

10
22 972733171 975
22 973609752 512
55 987399854 126
49 967364929 642
23 948126474 513
25 962813818 421
93 933323422 113
58 950364131 647
82 991906690 682
31 957667404 402

output:

972736672.681
973616306.987
987457697.397
967376069.315
948133283.102
962822722.648
933426898.318
950377057.363
991923706.585
957678776.965

result:

ok 10 numbers

Test #8:

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

input:

10
47 972371220 9743
65 949941115 9400
86 921812690 9736
11 927065494 9182
71 923766617 9378
63 941828720 9029
96 917539847 9084
88 952051332 9499
91 958386812 9427
64 950375055 9887

output:

972371465.902
949941549.32
921813131.821
927065583.858
923767096.494
941829231.443
917540568.647
952051875.055
958387391.921
950375326.496

result:

ok 10 numbers

Test #9:

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

input:

10
98 46 9403
99 89 9661
80 62 9450
25 20 9283
68 74 9328
54 14 9286
4 80 9574
35 61 9420
77 47 9943
22 9 9358

output:

153.142614059
194.596832626
150.264550265
48.475708284
152.229845626
73.2285160457
87.7376227282
101.910828025
124.710851856
33.1267364822

result:

ok 10 numbers

Test #10:

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

input:

10
89 77 65
53 41 913
47 67 488
89 13 267
20 60 427
58 72 690
23 60 677
43 38 775
52 68 343
83 61 805

output:

15149.2838382
795.195959679
1340.26261032
3590.64750473
734.463107825
1204.0440418
568.432537047
761.453449762
1986.66955837
1378.15844834

result:

ok 10 numbers

Test #11:

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

input:

20
5 1000000000 4
3 999999979 5
5 1000000000 2
2 999999999 4
3 999999983 1
3 999999984 1
3 999999987 3
3 999999974 1
2 999999998 1
1 999999981 2
4 999999971 4
3 999999992 1
5 999999973 4
4 999999984 4
3 999999972 4
2 999999994 4
2 999999980 5
4 999999970 5
2 999999980 2
4 999999983 4

output:

1000153595.97
1000078103.94
1000289896.62
1000066017.49
1000342407.04
1000342408.04
1000125100.24
1000342398.04
1000236387.47
1000066005.59
1000125078.48
1000342416.04
1000153568.97
1000125091.48
1000095959.57
1000066012.49
1000053684.65
1000101835.89
1000125098.99
1000125090.48

result:

ok 20 numbers

Test #12:

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

input:

10000
15 999999991 6
16 999999975 2
12 999999978 9
7 999999993 4
19 999999980 5
20 999999977 5
13 999999995 10
11 999999979 6
19 999999995 5
6 999999982 10
15 999999978 1
2 999999974 5
12 999999980 4
18 999999997 1
12 999999992 10
20 999999970 6
2 999999999 2
13 999999984 1
16 999999984 2
16 9999999...

output:

1000289834.63
1000834644.98
1000162916.05
1000209141.24
1000424660.56
1000444958.76
1000159181.22
1000218214.15
1000424675.56
1000078088.9
1001470863.71
1000053678.65
1000342357.17
1001732290.59
1000147893.03
1000376844.54
1000125117.99
1001293330.75
1000834653.98
1000578025.38
1000050562.03
1000251...

result:

ok 10000 numbers

Test #13:

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

input:

50
3 999999983 9
8 999999973 7
6 999999988 9
17 999999995 10
19 999999993 6
13 999999989 6
17 999999995 1
8 999999999 7
9 999999971 3
15 999999986 8
2 1000000000 8
9 999999975 4
8 999999980 2
4 999999970 9
2 999999990 10
8 999999983 3
15 999999985 5
16 999999991 7
20 999999986 5
15 999999990 6
15 99...

output:

1000045336.02
1000141407.88
1000086075.42
1000203604.15
1000359647.07
1000254285.63
1001645751.82
1000141433.88
1000342363.8
1000222739.47
1000034735.24
1000263227.65
1000445022.53
1000059162.75
1000028221.66
1000307471.63
1000342346.55
1000267025.81
1000444967.76
1000289833.63
1000181530.31
1000150...

result:

ok 50 numbers