QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#563199#8795. Mysterious SequenceZhengxi-LiuWA 0ms3872kbC++141002b2024-09-14 04:53:402024-09-14 04:53:41

Judging History

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

  • [2024-09-14 04:53:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3872kb
  • [2024-09-14 04:53:40]
  • 提交

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'