QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#657576#6423. FireworksLmR308WA 1ms4300kbC++171.4kb2024-10-19 15:00:192024-10-19 15:00:20

Judging History

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

  • [2024-10-19 15:00:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4300kb
  • [2024-10-19 15:00:19]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define int128 __int128_t
#define int long long
#define PII pair<int, int>
#define PDD pair<double, double>
#define fi first    
#define se second
#define lowbit(x) x & -x
#define all(x) x.begin(), x.end()
#define INF 0x3f3f3f3f3f3f3f3f
#define ls(x) x << 1
#define rs(x) x << 1 | 1
#define ull unsigned long long
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e6 + 10, M = 5e6 + 10, mod = 998244353;
const double eps = 1e-8;

int t, n, m, k;	
string sr;

void solve() {
	int p;
	cin >> n >> m >> p;
	auto cal = [&](int x) {
		int res = n * x + m;
		double temp = 1 - 1.0 * p / 10000;
		double te = 1 - pow(temp, x);
		double ans = 1.0 * res / te;
		return ans;
	};
	if (p == 10000) {
		cout << 1.0 * (n + m) << "\n";
		return;
	}
	int l = 1, r = 1e9;
	while (r > l) {
		int mid1 = (l + r) >> 1, mid2 = (mid1 + r) >> 1;
		if (cal(mid1) < cal(mid2)) r = mid2 - 1;
		else l = mid1 + 1;
	}
	double res = 1.0;
	double temp = 1.0 - 1.0 * p / 10000;
	res = 1.0 * (n * 1 + m) / (1 - temp);
	temp = pow(temp, l);
	res = min(res, 1.0 * (n * l + m) / (1 - temp));
	cout << res << "\n";
}

signed main() {
	cin.tie(nullptr)->sync_with_stdio(false);
	cout.setf(ios::fixed), cout.precision(15);
	t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}	

詳細信息

Test #1:

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

input:

3
1 1 5000
1 1 1
1 2 10000

output:

4.000000000000000
10141.588230252444191
3.000000000000000

result:

ok 3 numbers

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 4300kb

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.729805650548002
200.348432055749129
177.346278317152098
443.213296398892055
90.293453724604973
149.569421362743611
190.672507085802636
176.643768400392560
139.349701393497014
275.133110248423009
167.364016736401652
207.190737355271182
300.732217573221703
589.058848950519405
109.940181804096099
10...

result:

wrong answer 4th numbers differ - expected: '416.83988', found: '443.21330', error = '0.06327'