QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623054#8795. Mysterious Sequencerns_rds#WA 1ms3884kbC++23834b2024-10-09 09:52:192024-10-09 09:52:20

Judging History

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

  • [2024-10-09 09:52:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3884kb
  • [2024-10-09 09:52:19]
  • 提交

answer

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

#define double long double

void solve() {
	const double inf = 1e9;
	const double ep = 1e-9;
	double a, b;
	cin >> a >> b;
	int n;
	cin >> n;
	double x, y;
	cin >> x >> y;
	double lo = -inf, hi = inf;
	auto calc = [&](double val) {
		double fi = x, se = val;
		for (int i = 3; i <= n; i++) {
			double tmp = a * fi + b * se;
			fi = se, se = tmp;
		}
		return se;
	};
	while (hi > lo + ep) {
		double mid = (hi + lo) / 2;
		if (calc(mid) <= y) lo = mid;
		else hi = mid;
	}
	cout << setprecision(12) << fixed;
	cout << x << "\n";
	for (int i = 2; i < n; i++) {
		cout << lo << "\n";
		double tmp = a * x + b * lo;
		x = lo, lo = tmp;
	}
	cout << y << "\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1.0 1.0 10 1 10

output:

1.000000000000
-0.323529412462
0.676470587538
0.352941175076
1.029411762615
1.382352937691
2.411764700306
3.794117637997
6.205882338303
10.000000000000

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

1 1 2 1 100

output:

1.000000000000
100.000000000000

result:

ok 2 numbers

Test #3:

score: 0
Accepted
time: 1ms
memory: 3880kb

input:

1 1 5 50 100

output:

50.000000000000
0.000000000000
50.000000000000
50.000000000000
100.000000000000

result:

ok 5 numbers

Test #4:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

0.25 0.25 10 1 1

output:

1.000000000000
55.875536480662
14.218884120166
17.523605150207
7.935622317593
6.364806866950
3.575107296136
2.484978540771
1.515021459227
1.000000000000

result:

ok 10 numbers

Test #5:

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

input:

0.25 0.63 6 93 12

output:

93.000000000000
-2.196895156244
21.865956051566
13.226328523426
13.799075982650
12.000000000000

result:

wrong answer 2nd numbers differ - expected: '-14.2048080', found: '-2.1968952', error = '0.8453414'