QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#602899#6423. Fireworkslonelywolf#WA 1ms3808kbC++20947b2024-10-01 13:25:572024-10-01 13:25:58

Judging History

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

  • [2024-10-01 13:25:58]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3808kb
  • [2024-10-01 13:25:57]
  • 提交

answer

#include <bits/stdc++.h>  
using namespace std;  

#define int long long  

using db = 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) {
		if (x == 0) {
			return 1e18;
		}
		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 = 1e18;
	for (int i = l; i <= r; i++) {
		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: 3808kb

input:

3
1 1 5000
1 1 1
1 2 10000

output:

4.0000000000
10141.5852891161
3.0000000000

result:

ok 3 numbers

Test #2:

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

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'