QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623069#8795. Mysterious Sequencerns_rds#WA 1ms3940kbC++23836b2024-10-09 09:58:372024-10-09 09:58:37

Judging History

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

  • [2024-10-09 09:58:37]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3940kb
  • [2024-10-09 09:58:37]
  • 提交

answer

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

#define double long double

void solve() {
	const double inf = 1e10;
	const double ep = 1e-12;
	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(20) << 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: 3880kb

input:

1.0 1.0 10 1 10

output:

1.00000000000000000000
-0.32352941176519730253
0.67647058823480269747
0.35294117646960539495
1.02941176470440809237
1.38235294117401348731
2.41176470587842157979
3.79411764705243506699
6.20588235293085664678
10.00000000000000000000

result:

ok 10 numbers

Test #2:

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

input:

1 1 2 1 100

output:

1.00000000000000000000
100.00000000000000000000

result:

ok 2 numbers

Test #3:

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

input:

1 1 5 50 100

output:

50.00000000000000000000
0.00000000000000000000
50.00000000000000000000
50.00000000000000000000
100.00000000000000000000

result:

ok 5 numbers

Test #4:

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

input:

0.25 0.25 10 1 1

output:

1.00000000000000000000
55.87553648068616948125
14.21888412017154237031
17.52360515021442796332
7.93562231759649258341
6.36480686695273013657
3.57510729613730567989
2.48497854077250895401
1.51502145922745365847
1.00000000000000000000

result:

ok 10 numbers

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3828kb

input:

0.25 0.63 6 93 12

output:

93.00000000000000000000
-2.19689515610099162196
21.86595605165637527800
13.22632852351826851945
13.79907598273060298673
12.00000000000000000000

result:

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