QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#506265#6423. FireworksGrunrayWA 1ms3904kbC++202.4kb2024-08-05 16:17:572024-08-05 16:17:57

Judging History

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

  • [2024-08-05 16:17:57]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3904kb
  • [2024-08-05 16:17:57]
  • 提交

answer

#define _CRT_SECURE_NO_WARNINGS
#define itn int
#define PII pair<int, int>
#define PLI pair<long long, int>
#define fep(i, a, b) for(int i = (a); i >= (b); --i)
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#include<bits/stdc++.h>
#include<unordered_map>
using ll = long long;
using ldou = long double;
using unll = unsigned long long;
using namespace std;

inline int read() {
	int x = 0, f = 1;
	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;
}

ll gcd(ll a, ll b) { // 最大公约数
	while (b ^= a ^= b ^= a %= b)
		;
	return a;
}
ll lcm(ll a, ll b) { // 最小公倍数
	return a / gcd(a, b) * b;
}
ll qmi(ll m, ll k, ll p) { // 快速幂
	//求 m^k mod p,时间复杂度 O(logk)。
	//m为底数,k为幂
	ll res = 1 % p, t = m;
	while (k) {
		if (k & 1) res = res * t % p;
		t = t * t % p;
		k >>= 1;
	}
	return res;
}
unll qmi(unll m, unll k, unll p) { //龟速乘
	ll res = 0, t = m;
	while (k) {
		if (k & 1) res = (res + t) % p;
		k >>= 1;
		t = (t << 1) % p;
	}
	return res;
}

////////////////////////////////////////////////////////////////////////////////


const int N = 1e5 + 50;
const int M = 2e5 + 50;
const ll INF = 2e18;
const ll MODE = ll(998244353);
const double Pi = 3.1415926;
const double eps = 1e-6;
const int dx[4] = { 1,-1, 0, 0 };
const int dy[4] = { 0, 0, 1,-1 };
//priority_queue<int> p;//这是一个大根堆q
//priority_queue<int, vector<int>, greater<int> >q;//这是一个小根堆q
//priority_queue<ll, vector<ll>, greater<ll> >pq; // 小根

ll n, m;
string str;

ldou p;

ldou check(ldou mid) {
	return 1.0 * (n * mid + m) / (1 - pow((1 - p), mid));
}

void solve() {
	
	
	cin >> n >> m >> p;

	p /= 1e4;

	ll l, r;
	l = 1.0, r = 1e9 + 10000000;
	ll mid1, mid2;
	//ldou res = 1e9;

	while (l < r) {
		mid1 = (l * 2 + r) / 3;
		mid2 = (l + r * 2) / 3;

		//res = min(res, min(l, r));

		if (check(mid1) <= check(mid2)) {
			r = mid2 - 1;
		}
		else
			l = mid1 + 1;
	}

	cout << fixed << setprecision(10) << check(l) << '\n';




	
}

signed main() {
	std::ios::sync_with_stdio(false); std::cin.tie(0), std::cout.tie(0);
	/*freopen("out.txt", "r", stdin);
	freopen("wrt.txt", "w", stdout);*/
	int TTT = 1; cin >> TTT;
	while (TTT--) {
		solve();
	}
	/*while (cin >> n >> m) {
		solve();
	}*/

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1 1 5000
1 1 1
1 2 10000

output:

4.0000000000
10141.5852891136
3.0000000000

result:

ok 3 numbers

Test #2:

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

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.3484320557
177.3462783172
443.2132963989
90.2934537246
149.5694213627
190.6725070858
176.6437684004
139.3497013935
277.3137564429
167.3640167364
207.1907373553
300.7322175732
589.0588489505
113.6787178531
10796.8872669046
229.7921478060
303.9373704812
153.4419337888
68.5345696432

result:

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