QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#619906#6423. FireworksxDarkbluex#AC ✓154ms4036kbC++171.0kb2024-10-07 15:52:212024-10-07 15:52:51

Judging History

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

  • [2024-10-07 15:52:51]
  • 评测
  • 测评结果:AC
  • 用时:154ms
  • 内存:4036kb
  • [2024-10-07 15:52:21]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
int T;
double n,m,p;
double qpow(double a,int x)
{
	double ans=1;
	while(x)
	{
		if(x&1)
		{
			ans=(ans*a);
		}
		a=(a*a);
		x>>=1;
	}
	return ans;
}
int check(double x)
{
	double py=-n/(x*log(p)),y=log(py)/log(p);
	double y1=floor(y),y2=ceil(y);
	if(y1>=1&&y1*n+m+x*(qpow(p,(int)y1)-1)<=0)
	{
		return 1;
	}
	if(y2>=1&&y2*n+m+x*(qpow(p,(int)y2)-1)<=0)
	{
		return 1;
	}
	if(n+m+x*(p-1)<=0)
	{
		return 1;
	}
	return 0;
}
void solve()
{
	cin >> n >> m >> p;
	//scanf("%lf%lf%lf",&n,&m,&p);
	p=1-p/10000;
	double l=0,r=1e18+7;
	while(r-l>1e-6)
	{
		double mid=(l+r)/2.0;
		if(check(mid))
		{
			r=mid-1e-6;
		}
		else
		{
			l=mid+1e-6;
		}
	}
	double ans=(l+r)/2.0;
	cout << fixed << setprecision(12) << ans << '\n';
//	printf("%.12lf\n",ans);
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin>>T;
	//T=10000;
	while(T--)
	{
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1 1 5000
1 1 1
1 2 10000

output:

4.000000424026
10141.585289078651
3.000000274814

result:

ok 3 numbers

Test #2:

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

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.729806437299
200.348431525999
177.346279078908
416.839878522664
90.293453924138
149.569421760480
190.672507817356
164.601521915139
139.349701245338
275.133111059786
167.364017302212
207.190737204140
300.732216892321
589.058848968980
101.877028178896
10796.887266376592
229.792147114229
303.9373697...

result:

ok 20 numbers

Test #3:

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

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.029165524524
1951513567.023025602219
2010693554.594594088383
2021655257.390944587998
2031572260.121135033667
2023744964.098167791846
2057899480.771301760105
1934924193.052567215636
1909560538.206647544168
1938062078.640385374660

result:

ok 10 numbers

Test #4:

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

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.665046427690
1035512471.349745914864
940905431.728981761669
1063626543.685167076823
1001518880.766062179813
1045380761.465876407630
1009160282.760075983999
1022500825.108129279630
960922565.450317963492
1033287652.536929607915

result:

ok 10 numbers

Test #5:

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

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.177214670926
18075237355.679701615125
102118356741.573033176363
20399770568.927789308131
84356173628.318584553897
282304390588.235296130180
80421952434.782608889043
24940588507.853402424604
458817209500.000003695488
14331610061.162078734487

result:

ok 10 numbers

Test #6:

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

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.294285900891
31076848077.761112246662
40771434362.895146943629
16579259543.363533029333
33660076568.701946720481
20209258011.501921791583
34581380127.395107500255
24798113234.332959450781
33145494087.728286094964
26925682159.120105609298

result:

ok 10 numbers

Test #7:

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

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.681293320027
973616306.986935816298
987457697.396779215953
967376069.315485631174
948133283.101613874780
962822722.647579467215
933426898.317727456044
950377057.363343751116
991923706.585391855158
957678776.965345360804

result:

ok 10 numbers

Test #8:

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

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.901789892756
949941549.320473236323
921813131.821225952939
927065583.858390765730
923767096.493965758302
941829231.442623418756
917540568.647066498583
952051875.055214560649
958387391.921013260609
950375326.495619652793

result:

ok 10 numbers

Test #9:

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

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.142613704860
194.596832968681
150.264549605684
48.475708633434
152.229846368687
73.228516055099
87.737622995665
101.910828433086
124.710852680055
33.126737092802

result:

ok 10 numbers

Test #10:

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

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.283837472481
795.195960077616
1340.262609584741
3590.647504885622
734.463107152526
1204.044041556725
568.432536257792
761.453449711676
1986.669558068235
1378.158448400230

result:

ok 10 numbers

Test #11:

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

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.966845846560
1000078103.937719450390
1000289896.621387683030
1000066017.486277245567
1000342407.043464891962
1000342408.043494819722
1000125100.235101957282
1000342398.043193888268
1000236387.472665372654
1000066005.589947655506
1000125078.477629684668
1000342416.043734241335
1000153568.9...

result:

ok 20 numbers

Test #12:

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

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.627433393907
1000834644.980372959806
1000162916.054420443776
1000209141.238759557193
1000424660.557302240573
1000444958.758943613793
1000159181.222366447852
1000218214.149087087775
1000424675.557871924771
1000078088.897094372369
1001470863.708315407217
1000053678.649081465323
1000342357.1...

result:

ok 10000 numbers

Test #13:

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

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.023083771812
1000141407.881453893322
1000086075.416390550381
1000203604.146658956714
1000359647.071661695489
1000254285.628475211735
1001645751.815485950327
1000141433.881750594883
1000342363.795863466279
1000222739.470001934271
1000034735.235237181361
1000263227.651192077785
1000445022.5...

result:

ok 50 numbers