QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#779445#8795. Mysterious Sequencewoodie_0064#WA 0ms3932kbC++20964b2024-11-24 19:11:012024-11-24 19:11:01

Judging History

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

  • [2024-11-24 19:11:01]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3932kb
  • [2024-11-24 19:11:01]
  • 提交

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 = -1, 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: 3932kb

input:

1.0 1.0 10 1 10

output:

1.0000000000
-0.3235294118
0.6764705882
0.3529411764
1.0294117647
1.3823529411
2.4117647057
3.7941176468
6.2058823526
10.0000000000

result:

ok 10 numbers

Test #2:

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

input:

1 1 2 1 100

output:

1.0000000000
100.0000000000

result:

ok 2 numbers

Test #3:

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

input:

1 1 5 50 100

output:

50.0000000000
-0.0000000000
50.0000000000
49.9999999999
100.0000000000

result:

ok 5 numbers

Test #4:

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

input:

0.25 0.25 10 1 1

output:

1.0000000000
55.8755363091
14.2188840773
17.5236050966
7.9356222935
6.3648068475
3.5751072852
2.4849785332
1.5150214546
1.0000000000

result:

ok 10 numbers

Test #5:

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

input:

0.25 0.63 6 93 12

output:

93.0000000000
-1.0000000000
22.6200000000
14.0006000000
14.4753780000
12.0000000000

result:

wrong answer 2nd numbers differ - expected: '-14.2048080', found: '-1.0000000', error = '0.9296013'