QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#576162#8795. Mysterious SequenceLegend_dy#WA 0ms3868kbC++201.4kb2024-09-19 18:54:582024-09-19 18:55:00

Judging History

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

  • [2024-09-19 18:55:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3868kb
  • [2024-09-19 18:54:58]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

// #define int long long

struct Matrix {
    double a[2][2];
    Matrix() {
        a[0][0] = a[0][1] = a[1][0] = a[1][1] = 0;
    }
    Matrix operator*(Matrix v) {
        Matrix res;
        for(int k = 0; k < 2; k++) {
            for(int i = 0; i < 2; i++)
                for(int j = 0; j < 2; j++)
                    res.a[i][j] += a[i][k] * v.a[k][j];
        }
        return res;
    }
    Matrix operator+(Matrix v) {
        Matrix res;
        for(int i = 0; i < 2; i++)
            for(int j = 0; j < 2; j++)
                res.a[i][j] = a[i][j] * v.a[i][j];
        return res;
    }
};
const int N = 105;
int n;
double A, B, x[N];
Matrix qpow(Matrix a, int b) {
    Matrix res;
    res.a[0][0] = 1; res.a[1][1] = 1;
    while(b) {
        if(b & 1) res = res * a;
        a = a * a; b >>= 1;
    }
    return res;
}
void solve() {
    cin >> A >> B >> n;
    cin >> x[1] >> x[n];
    Matrix m;
    m.a[0][0] = A; m.a[0][1] = B;
    m.a[1][0] = 1;
    m = qpow(m, n - 2);
    x[2] = (x[n] - m.a[0][1] * x[1]) / m.a[0][0];
    for(int i = 1; i <= n; i++) {
        if(i >= 3) x[i] = (x[i - 1] + x[i - 2]);
        cout << fixed << setprecision(10) << x[i] << endl;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1; 
    // cin >> T;
    while (T--) {
        solve();
    }

    return 0;
}

詳細信息

Test #1:

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

input:

1.0 1.0 10 1 10

output:

1.0000000000
-0.3235294118
0.6764705882
0.3529411765
1.0294117647
1.3823529412
2.4117647059
3.7941176471
6.2058823529
10.0000000000

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

1 1 2 1 100

output:

1.0000000000
100.0000000000

result:

ok 2 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

1 1 5 50 100

output:

50.0000000000
0.0000000000
50.0000000000
50.0000000000
100.0000000000

result:

ok 5 numbers

Test #4:

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

input:

0.25 0.25 10 1 1

output:

1.0000000000
55.8755364807
56.8755364807
112.7510729614
169.6266094421
282.3776824034
452.0042918455
734.3819742489
1186.3862660944
1920.7682403433

result:

wrong answer 3rd numbers differ - expected: '14.2188841', found: '56.8755365', error = '3.0000000'