QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#488631#8795. Mysterious Sequenceucup-team4479#WA 0ms4000kbC++20780b2024-07-24 12:15:212024-07-24 12:15:22

Judging History

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

  • [2024-07-24 12:15:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4000kb
  • [2024-07-24 12:15:21]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
double x[20];
struct linear {
    double k, b;
    linear operator * (const double &rhs) {
        return {k * rhs, b * rhs};
    }
    linear operator + (const linear &rhs) {
        return {k + rhs.k, b + rhs.b};
    }
} y[20];
int main() {
    cin.tie(nullptr) -> ios::sync_with_stdio(false);
    cout.tie(0);
    double A, B;
    int n;
    cin >> A >> B >> n >> x[1] >> x[10];
    y[1] = {0, x[1]};
    y[2] = {1, 0};
    for (int i = 3; i <= n; ++i) {
        y[i] = y[i - 1] * A + y[i - 2] * B;
    }
    x[2] = (x[10] - y[10].b) / y[10].k;
    for (int i = 3; i <= n; ++i)
        x[i] = A * x[i - 1] + B * x[i - 2];
    for (int i = 1; i <= n; ++i)
        printf("%.9lf\n", x[i]);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1.0 1.0 10 1 10

output:

1.000000000
-0.323529412
0.676470588
0.352941176
1.029411765
1.382352941
2.411764706
3.794117647
6.205882353
10.000000000

result:

ok 10 numbers

Test #2:

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

input:

1 1 2 1 100

output:

1.000000000
inf

result:

wrong output format Expected double, but "inf" found