QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#622966#8795. Mysterious Sequencerns_rds#WA 0ms4024kbC++231.4kb2024-10-09 09:03:542024-10-09 09:03:55

Judging History

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

  • [2024-10-09 09:03:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4024kb
  • [2024-10-09 09:03:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using Z = long double; // not necessary, maybe MINT

struct Mat {
    vector<vector<Z>> a;
    static int D;
    const static void setD(int _D) {
        D = _D;
    }
    Mat(int k = 0) {
        a.assign(D, vector<Z>(D, 0));
        for (int i = 0; i < D; i++)
            a[i][i] = k;
    }
    Mat operator*(const Mat &x) {
        Mat res;
        for (int i = 0; i < D; i++)
            for (int j = 0; j < D; j++)
                for (int k = 0; k < D; k++)
                    res.a[i][j] += a[i][k] * x.a[k][j];
        return res;
    }
    Mat pow(long long k) {
        Mat res = Mat(1.0), b = *this;
        for (; k; k >>= 1) {
            if (k & 1) res = res * b;
            b = b * b;
        }
        return res;
    }
};

int Mat::D = 2;

// See RNS_CONTEST_2023::D

int main() {
    long double A, B;
    int n;
    long double x1, xn;
    cin >> A >> B >> n >> x1 >> xn;
    Mat matrix;
    matrix.a[0][0] = A, matrix.a[0][1] = B;
    matrix.a[1][0] = 1, matrix.a[1][1] = 0;
    Mat tmp = matrix.pow(n - 2);
    long double x2 = 1.0 * (xn - tmp.a[0][1] * x1) / tmp.a[0][0];
    cout << setprecision(8) << fixed << x1 << '\n'
         << x2 << '\n';
    for (int i = 3; i < n; i++) {
        long double ans = x1 + x2;
        cout << ans << '\n';
        x1 = x2, x2 = ans;
    }
    cout << xn << '\n';
}

详细

Test #1:

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

input:

1.0 1.0 10 1 10

output:

1.00000000
-0.32352941
0.67647059
0.35294118
1.02941176
1.38235294
2.41176471
3.79411765
6.20588235
10.00000000

result:

ok 10 numbers

Test #2:

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

input:

1 1 2 1 100

output:

1.00000000
100.00000000
100.00000000

result:

wrong output format Extra information in the output file