QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#779456#8795. Mysterious Sequencewoodie_0064#WA 0ms3964kbC++20966b2024-11-24 19:12:512024-11-24 19:12:55

Judging History

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

  • [2024-11-24 19:12:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3964kb
  • [2024-11-24 19:12:51]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
using ld = long double;
const int N = 1e5 + 3;
int T;
int n, num;


void work(){
	ld a, b, x1, xn;
	cin >> a >> b >> n >> x1 >> xn;
	if(n == 2){
		cout << x1 << "\n" << xn;
		return;
	}
	ld l = -2e9, r = 2e9, ans, x11, x2, x22, xi; 
	while(l < r){
		x2 = (l + r) / 2;
		x11 = x1, x22 = x2;
		for(int i = 3; i <= n; ++i){
			xi = a * x11 + b * x22;
			x11 = x22, x22 = xi;
		}
		if(abs(xi - xn) < 1e-8){
			break;
		}else if(xi > xn) r = x2;
		else l = x2;
	}
	cout << x1 << "\n" << x2 << "\n";
	x11 = x1, x22 = x2;
	for(int i = 3; i < n; ++i){
		xi = a * x11 + b * x22;
		x11 = x22, x22 = xi;
		cout << xi << "\n";
	}
	cout << xn;

}


int main(){
//	freopen("test.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int T = 1;
	while(T--){
		work();
	}	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1.0 1.0 10 1 10

output:

1.0000000000
-0.3235294116
0.6764705884
0.3529411768
1.0294117652
1.3823529420
2.4117647072
3.7941176493
6.2058823565
10.0000000000

result:

ok 10 numbers

Test #2:

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

input:

1 1 2 1 100

output:

1.0000000000
100.0000000000

result:

ok 2 numbers

Test #3:

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

input:

1 1 5 50 100

output:

50.0000000000
0.0000000000
50.0000000000
50.0000000000
100.0000000000

result:

ok 5 numbers

Test #4:

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

input:

0.25 0.25 10 1 1

output:

1.0000000000
55.8755361979
14.2188840495
17.5236050618
7.9356222778
6.3648068349
3.5751072782
2.4849785283
1.5150214516
1.0000000000

result:

ok 10 numbers

Test #5:

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

input:

0.25 0.63 6 93 12

output:

93.0000000000
-2.1968951658
21.8659560456
13.2263285173
13.7990759773
12.0000000000

result:

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