QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#779444#8795. Mysterious Sequencewoodie_0064#WA 0ms3928kbC++20906b2024-11-24 19:09:202024-11-24 19:09:22

Judging History

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

  • [2024-11-24 19:09:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3928kb
  • [2024-11-24 19:09:20]
  • 提交

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;
	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: 3928kb

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

input:

1 1 2 1 100

output:

1.0000000000
2000000000.0000000000
100.0000000000

result:

wrong answer 2nd numbers differ - expected: '100.0000000', found: '2000000000.0000000', error = '19999999.0000000'