QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#602954 | #6423. Fireworks | lonelywolf# | WA | 2ms | 3824kb | C++20 | 1004b | 2024-10-01 13:45:28 | 2024-10-01 13:45:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
using db = long double;
db qpow(db a, int b) {
db ret = 1.0;
for (; b; b /= 2, a *= a) {
if (b % 2) {
ret *= a;
}
}
return ret;
}
void solve() {
int n, m, _p;
cin >> n >> m >> _p;
db p = 1.0 * _p / 10000;
auto calc = [&](int x) {
return 1.0 * (x * n + m) / (1 - qpow(1 - p, x));
};
int l = 0, r = 1e18;
while (r - l > 5) {
int lm = (2 * l + r) / 3;
int rm = (l + 2 * r) / 3;
if (calc(lm) < calc(rm)) {
r = rm;
} else {
l = lm;
}
}
db ans = -1;
for (int i = l; i <= r; i++) {
if (i <= 0) {
continue;
}
if (ans == -1) {
ans = calc(i);
} else {
ans = min(ans, calc(i));
}
}
cout << ans << "\n";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(10);
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3812kb
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: 2ms
memory: 3824kb
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 -9223372036854774784.0000000000 -9223372036854775808.0000000000 -9223372036854775808.0000000000 -9223372036854774784.0000000000 -9223372036854774784.0000000000 -9223372036854774784.0000000000 -9223372036854775808.0000000000 -9223372036854775808.0000000000 -9223372036854775808.000000000...
result:
wrong answer 2nd numbers differ - expected: '200.34843', found: '-9223372036854774784.00000', error = '46036656949182080.00000'