QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#506577#6423. FireworksmmzskmWA 1ms4032kbC++20747b2024-08-05 19:43:212024-08-05 19:43:22

Judging History

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

  • [2024-08-05 19:43:22]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4032kb
  • [2024-08-05 19:43:21]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cmath>	
#include<climits>
using namespace std;

int n, m;
long double p;

long double f(int x)
{
	long double pp = 1.0 - (long double)pow(1.0 - p, x);
	int t = n * x + m;
	return (long double)t / pp;
}

void solve()
{
	cin >> n >> m >> p;
	p /= 10000;
	int l = 1, r = 0x3f3f3f3f;
	while (l < r)
	{
		int mid1 = l + (r - l) / 3;
		int mid2 = r - (r - l) / 3;
		if (f(mid1) < f(mid2))
		{
			r = mid2 - 1;
		}
		else
		{
			l = mid1 + 1;
		}
	}
	cout << fixed << setprecision(12) << f(l) << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	int T;
	cin >> T;
	while (T--)
	{
		solve();
	}

	return 0;
}

详细

Test #1:

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

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: -100
Wrong Answer
time: 1ms
memory: 4032kb

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:

-2147483645.000000000000
-2147483611.000000000000
-2147483611.000000000000
-2147483622.000000000000
-2147483633.000000000000
-2147483613.000000000000
-2147483644.000000000000
-2147483647.000000000000
-2147483618.000000000000
-2147483639.000000000000
-2147483584.000000000000
-2147483608.000000000000
...

result:

wrong answer 1st numbers differ - expected: '89.72981', found: '-2147483645.00000', error = '23932780.40849'