QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#506434#6423. FireworksRailgun2334AC ✓190ms4080kbC++203.4kb2024-08-05 17:24:582024-08-05 17:24:58

Judging History

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

  • [2024-08-05 17:24:58]
  • 评测
  • 测评结果:AC
  • 用时:190ms
  • 内存:4080kb
  • [2024-08-05 17:24:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define re read()
#define MOD 998244353
#define i128 __int128
#define pll pair<ll,ll>
#define pii pair<int,int>
#define ull unsigned long long
#define INF 9223372036854775800
#define fr(i, x, y) for (int i = x, p = y; i <= p; ++i)
#define rp(i, x, y) for (int i = x, p = y; i >= p; --i)
#define Timeok ((double)clock() / CLOCKS_PER_SEC < MAX_TIME)
const double MAX_TIME = 1.0 - 0.0032;

inline ll read() {
	ll x = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch))
		f |= (ch == '-'), ch = getchar();
	while (isdigit(ch))
		x = (x << 1) + (x << 3) + (ch ^= 48), ch = getchar();
	return f ? -x : x;
}

void write(i128 x) {
	if (x < 0)
		putchar('-'), x = -x;
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + 48);
}

inline void W(i128 x, char ch) {
	write(x);
	putchar(ch);
}

ll ksm(ll a, ll b, ll mod) { //快速幂mod
	a %= mod;
	ll res = 1;
	while (b > 0)
	{
		if (b & 1)
			res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}
ll ksm(ll a, ll b) { //快速幂
	ll res = 1;
	while (b > 0)
	{
		if (b & 1)res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}

pii fib(ll n) { //计算第n和n+1位斐波那契数
	if (n == 0)return{ 0,1 };
	auto p = fib(n >> 1);
	ll c = p.first * (2 * p.second - p.first);
	ll d = p.first * p.first + p.second * p.second;
	if (n & 1)
		return { d,c + d };
	else
		return { c,d };
}

ll exgcd(ll a, ll b, ll& x, ll& y) { //扩展欧几里得
	ll x1 = 1, x2 = 0, x3 = 0, x4 = 1;
	while (b != 0) {
		ll c = a / b;
		std::tie(x1, x2, x3, x4, a, b) =
			std::make_tuple(x3, x4, x1 - x3 * c, x2 - x4 * c, b, a - b * c);
	}
	x = x1, y = x2;
	return a;
}

bool liEu(ll a, ll b, ll c, ll& x, ll& y) { //线性同余方程
	ll d = exgcd(a, b, x, y);
	if (c % d != 0) return 0;
	ll k = c / d;
	x *= k;
	y *= k;
	return 1;
}

ll r[105]; //取模数
ll CRT(int k, ll* a, ll* r) { //中国剩余定理
	ll n = 1, ans = 0;
	for (int i = 1; i <= k; i++) n = n * r[i];
	for (int i = 1; i <= k; i++) {
		ll m = n / r[i], b, y;
		exgcd(m, r[i], b, y);  // b * m mod r[i] = 1
		ans = (ans + a[i] * m * b % n) % n;
	}
	return (ans % n + n) % n;
}
/*
ll Lucas(ll n, ll m, ll p) {
  if (m == 0) return 1;
  return (C(n % p, m % p, p) * Lucas(n / p, m / p, p)) % p;
}
*/
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
/*------------C-O-D-E------------*/
const int N = 1e5 + 4;
//int n, m, M, mod=998244353;
long double pi[10005];
long double t1,t2,p;
long double check(long double i)
{
	return (t1*i+t2)/(1.0-pow(p,i));
}
void solve()
{
	std::cin>>t1>>t2>>p;
	if(p==10000)
	{
		printf("%.12Lf\n",t1+t2);
		return;
	}
	p=1.0-p*0.0001;
	//long double pp=1.0-p*0.0001;
	/*
	pi[0]=1;
	for(int i=1;i<=10000;i++)
	{
		pi[i]=pi[i-1]*pp;
	}
	for(int i=1;i<=10000;i++)
	{
		long double sum=(t1*i+t2)/(1.0-pi[i]);
	}
	*/
	int l=1,r=1e9;
	long double mid;
	long double lmid,rmid;
	while(r-l>1)
	{
		mid=(l+r)/2;
		lmid=mid-1e-6;
		rmid=mid+1e-6;
		if(check(rmid)>check(lmid))
		{
			r=mid;
		}
		else
		{
			l=mid;
		}
	}
	printf("%.12Lf\n",min(check(l),check(r)));
}
int main()
{
	ios::sync_with_stdio(false);
	std::cin.tie(0);std::cout.tie(0);
	ll T = 1;
	std::cin>>T;
	while (T--)
	{
		solve();
	}
}

详细

Test #1:

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

input:

3
1 1 5000
1 1 1
1 2 10000

output:

4.000000000000
10141.585289113577
3.000000000000

result:

ok 3 numbers

Test #2:

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

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.729805650548
200.348432055749
177.346278317152
416.839877800355
90.293453724605
149.569421362744
190.672507085803
164.601521115577
139.349701393497
275.133110248423
167.364016736402
207.190737355271
300.732217573222
589.058848950519
101.877028212449
10796.887266904624
229.792147806005
303.9373704...

result:

ok 20 numbers

Test #3:

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

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.029165721964
1951513567.023026222247
2010693554.594594498281
2021655257.390944703715
2031572260.121134744841
2023744964.098167301971
2057899480.771302281995
1934924193.052566768602
1909560538.206647162209
1938062078.640386069659

result:

ok 10 numbers

Test #4:

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

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.665046991897
1035512471.349745281448
940905431.728981570282
1063626543.685167310818
1001518880.766062554962
1045380761.465876623173
1009160282.760075917002
1022500825.108129040513
960922565.450318360934
1033287652.536929944006

result:

ok 10 numbers

Test #5:

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

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.177213810384
18075237355.679701186717
102118356741.573028966784
20399770568.927788963541
84356173628.318580128253
282304390588.235282838345
80421952434.782604746521
24940588507.853401929140
458817209499.999978005886
14331610061.162078818306

result:

ok 10 numbers

Test #6:

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

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.294281251729
31076848077.761110309511
40771434362.895144775510
16579259543.363532565534
33660076568.701945684850
20209258011.501920508221
34581380127.395106695592
24798113234.332959013060
33145494087.728285409510
26925682159.120104348287

result:

ok 10 numbers

Test #7:

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

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.681293441798
973616306.986935916881
987457697.396779324627
967376069.315485323605
948133283.101613932813
962822722.647579097946
933426898.317728194932
950377057.363343162695
991923706.585391661094
957678776.965345430828

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.901790268661
949941549.320472925087
921813131.821226126980
927065583.858390120906
923767096.493965991715
941829231.442622725968
917540568.647066358477
952051875.055215206638
958387391.921013795945
950375326.495618894463

result:

ok 10 numbers

Test #9:

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

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.142614059343
194.596832626022
150.264550264550
48.475708283960
152.229845626072
73.228516045660
87.737622728222
101.910828025478
124.710851855577
33.126736482154

result:

ok 10 numbers

Test #10:

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

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.283838238594
795.195959678696
1340.262610317281
3590.647504732402
734.463107824570
1204.044041798925
568.432537046959
761.453449761660
1986.669558374136
1378.158448339148

result:

ok 10 numbers

Test #11:

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

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.966846054245
1000078103.937719036883
1000289896.621388429950
1000066017.486277992022
1000342407.043464435323
1000342408.043494423968
1000125100.235101855826
1000342398.043194537226
1000236387.472664554720
1000066005.589947735716
1000125078.477628970344
1000342416.043734333361
1000153568.9...

result:

ok 20 numbers

Test #12:

score: 0
Accepted
time: 190ms
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.627433820046
1000834644.980373557599
1000162916.054420318513
1000209141.238760369190
1000424660.557301663328
1000444958.758943584864
1000159181.222366823233
1000218214.149087725498
1000424675.557871331403
1000078088.897094844840
1001470863.708314931311
1000053678.649080664909
1000342357.1...

result:

ok 10000 numbers

Test #13:

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

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.023083026288
1000141407.881453225855
1000086075.416390765517
1000203604.146658752230
1000359647.071662367147
1000254285.628474628495
1001645751.815485570813
1000141433.881750286149
1000342363.795862677332
1000222739.470001246431
1000034735.235237659188
1000263227.651191306883
1000445022.5...

result:

ok 50 numbers