QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#563199 | #8795. Mysterious Sequence | Zhengxi-Liu | WA | 0ms | 3872kb | C++14 | 1002b | 2024-09-14 04:53:40 | 2024-09-14 04:53:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1e2 + 7;
double a, b, x1, xn, s[N];
int n;
int check(double x){
for(int i = 2;i <= n;i ++)
s[i] = 0.0;
//cout << x << ' ';
s[2] = x;
for(int i = 3;i <= n;i ++){
s[i] = s[i - 1] * a + s[i - 2] * b;
//cout << s[i] << ' ';
}
if(s[n] > xn)
return 1;
else if(s[n] < xn)
return 2;
if(s[n] == xn)
return 0;
return 0;
}
int main(){
cin >> a >> b >> n >> x1 >> xn;
x1 *= 1.0;
s[1] = x1 * 1.0;
double l = -100000000.0, r = 100000000.0;
int t = 0;
while(t <= 1000){
t ++;
double mid = (l + r) / 2.0;
int flag = check(mid);
//cout << endl;
if(flag == 1)
r = mid;
else if(flag == 2)
l = mid;
else{
break;
}
}
for(int i = 1;i <= n;i ++)
cout << s[i] << endl;
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3872kb
input:
1.0 1.0 10 1 10
output:
1 -0.323529 0.676471 0.352941 1.02941 1.38235 2.41176 3.79412 6.20588 10
result:
wrong answer 5th numbers differ - expected: '1.0294118', found: '1.0294100', error = '0.0000017'