QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#554132#8795. Mysterious Sequenceucup-team3931#WA 0ms4044kbC++201.1kb2024-09-09 07:39:462024-09-09 07:39:47

Judging History

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

  • [2024-09-09 07:39:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4044kb
  • [2024-09-09 07:39:46]
  • 提交

answer

#ifdef LOCAL
#include "stdafx.h"
#else
#include <bits/stdc++.h>
#define IL inline
#define LL long long
#define eb emplace_back
#define sz(v) ((int) (v).size())
#define L(i, j, k) for (int i = (j); i <= (k); ++i)
#define R(i, j, k) for (int i = (j); i >= (k); --i)
#define FIO(FILE) freopen(FILE".in", "r", stdin), freopen(FILE".out", "w", stdout)
using namespace std;

using vi = vector<int>;
#endif

using db = double;
int n;
db A, B, x0, x1;

int main () {
  ios::sync_with_stdio(0), cin.tie(0);
  cout << fixed << setprecision(7);
  cin >> A >> B >> n >> x0 >> x1;
  db a = (A + sqrtl(A * A + 4 * B)) / 2;
  db b = (A - sqrtl(A * A + 4 * B)) / 2;

  db aa = powl(a, n);
  db bb = powl(b, n);

  db c2 = (a * x1 - aa * x0) / (a * bb - aa * b);
  db c1 = (b * x1 - bb * x0) / (b * aa - bb * a);

  assert((x0 - c1 * a - c2 * b) < 1e-7);
  assert((x1 - c1 * aa - c2 * bb) < 1e-7);

  db fst = x0;
  db scd = c1 * a * a + c2 * b * b;

  cout << fst << '\n' << scd << '\n';
  L (i, 3, n) {
    db cur = fst * A + scd * B;
    cout << cur << '\n';
    fst = scd;
    scd = cur;
  }
}
// I love WHQ!

詳細信息

Test #1:

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

input:

1.0 1.0 10 1 10

output:

1.0000000
-0.3235294
0.6764706
0.3529412
1.0294118
1.3823529
2.4117647
3.7941176
6.2058824
10.0000000

result:

ok 10 numbers

Test #2:

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

input:

1 1 2 1 100

output:

1.0000000
100.0000000

result:

ok 2 numbers

Test #3:

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

input:

1 1 5 50 100

output:

50.0000000
-0.0000000
50.0000000
50.0000000
100.0000000

result:

ok 5 numbers

Test #4:

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

input:

0.25 0.25 10 1 1

output:

1.0000000
55.8755365
14.2188841
17.5236052
7.9356223
6.3648069
3.5751073
2.4849785
1.5150215
1.0000000

result:

ok 10 numbers

Test #5:

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

input:

0.25 0.63 6 93 12

output:

93.0000000
-14.2048080
14.3009710
5.4584097
7.0140409
5.7834482

result:

wrong answer 3rd numbers differ - expected: '55.0387980', found: '14.3009710', error = '0.7401656'