QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#488636#8795. Mysterious Sequenceucup-team4479#WA 0ms4068kbC++20807b2024-07-24 12:19:082024-07-24 12:19:09

Judging History

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

  • [2024-07-24 12:19:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4068kb
  • [2024-07-24 12:19:08]
  • 提交

answer

#include<bits/stdc++.h>
#define double long double
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, 0};
    for (int i = 3; i <= n; ++i) {
        y[i] = y[i - 1] * A + y[i - 2] * B;
    }
    x[2] = (x[n] - y[n].b) / y[n].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: 4068kb

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: 3812kb

input:

1 1 2 1 100

output:

1.000000000
0.000000000

result:

wrong answer 2nd numbers differ - expected: '100.0000000', found: '0.0000000', error = '1.0000000'