QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#450377 | #8795. Mysterious Sequence | kmiao | AC ✓ | 0ms | 3984kb | C++20 | 976b | 2024-06-22 11:15:03 | 2024-06-22 11:15:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
double a, b;
int n, x1, xn;
double f (double x2) {
vector<double> v(n + 1);
v[1] = x1;
v[2] = x2;
for (int i = 3; i <= n; i++) {
v[i] = a * v[i-1] + b * v[i-2];
}
return fabs(v[n] - xn);
}
int main() {
cin >> a >> b >> n >> x1 >> xn;
int N = 100;
double l = -10000, r = 10000;
for (int i = 0; i < N; i++) {
double rg = (r - l) / 3;
double m1 = l + rg;
double m2 = r - rg;
if (f(m1) > f(m2)) {
l = m1;
} else {
r = m2;
}
}
vector<double> v(n + 1);
v[1] = x1;
v[2] = l;
for (int i = 3; i < n; i++) {
v[i] = a * v[i-1] + b * v[i-2];
}
v[n] = xn;
cout << x1 << endl;
for (int i = 2; i < n; i++) {
cout << setprecision(10) << v[i] << endl;
}
cout << xn << endl;
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3720kb
input:
1.0 1.0 10 1 10
output:
1 -0.3235294118 0.6764705882 0.3529411765 1.029411765 1.382352941 2.411764706 3.794117647 6.205882353 10
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
1 1 2 1 100
output:
1 100
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
1 1 5 50 100
output:
50 -2.196244546e-14 50 50 100
result:
ok 5 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
0.25 0.25 10 1 1
output:
1 55.87553648 14.21888412 17.52360515 7.935622318 6.364806867 3.575107296 2.484978541 1.515021459 1
result:
ok 10 numbers
Test #5:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
0.25 0.63 6 93 12
output:
93 -14.20480796 55.03879801 4.810670489 35.87711037 12
result:
ok 6 numbers
Test #6:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
0.25 0.80 10 5 63
output:
5 78.76953618 23.69238405 68.93872496 36.18858848 64.19812709 45.00040255 62.60860231 51.65247262 63
result:
ok 10 numbers
Test #7:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
0.25 0.99 3 18 30
output:
18 48.72 30
result:
ok 3 numbers
Test #8:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
0.28 0.64 9 6 10
output:
6 20.95040335 9.706112938 16.12596977 10.72718381 13.32423212 10.59618263 11.49443969 10
result:
ok 9 numbers
Test #9:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
0.31 0.40 7 10 49
output:
10 240.115064 78.43566984 120.3610832 68.68620374 69.43715646 49
result:
ok 7 numbers
Test #10:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
0.32 0.28 5 36 6
output:
36 10.12137681 13.31884058 7.096014493 6
result:
ok 5 numbers
Test #11:
score: 0
Accepted
time: 0ms
memory: 3984kb
input:
0.35 0.65 10 86 82
output:
86 79.53392479 83.73687368 81.0049569 82.7807028 81.62646796 82.37672061 81.88905639 82.20603813 82
result:
ok 10 numbers
Test #12:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
0.36 0.68 8 72 59
output:
72 38.23991864 62.72637071 48.58463813 60.14440181 54.68953858 60.58642712 59
result:
ok 8 numbers
Test #13:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
0.43 0.61 2 93 84
output:
93 84
result:
ok 2 numbers
Test #14:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
0.46 0.96 6 65 35
output:
65 -16.61742366 54.75598512 9.235026437 56.81385787 35
result:
ok 6 numbers
Test #15:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
0.50 0.90 4 19 1
output:
19 -6.565217391 13.8173913 1
result:
ok 4 numbers
Test #16:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
0.54 0.35 3 16 22
output:
16 30.37037037 22
result:
ok 3 numbers
Test #17:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
0.55 0.89 10 74 13
output:
74 -48.32193708 39.28293461 -21.40090996 23.19131132 -6.291588641 17.17989332 3.849427437 17.40729015 13
result:
ok 10 numbers
Test #18:
score: 0
Accepted
time: 0ms
memory: 3980kb
input:
0.56 0.36 3 31 88
output:
31 137.2142857 88
result:
ok 3 numbers
Test #19:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
0.57 0.93 7 71 48
output:
71 -34.08056536 46.60407774 -5.130601472 40.41734946 18.26642982 48
result:
ok 7 numbers
Test #20:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
0.58 0.41 8 30 69
output:
30 89.43212168 64.17063058 73.88613562 69.1639172 70.40838758 69.19407085 69
result:
ok 8 numbers
Test #21:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
0.58 0.49 6 31 96
output:
31 99.55761354 72.93341585 91.08461183 88.56644863 96
result:
ok 6 numbers
Test #22:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
0.61 0.29 8 62 25
output:
62 34.40765126 38.96866727 33.7491059 31.8878681 29.23884025 27.08317431 25
result:
ok 8 numbers
Test #23:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
0.63 0.89 9 37 85
output:
37 -5.887853302 29.22065242 13.16882159 34.30273825 33.33097631 51.52795212 62.12717875 85
result:
ok 9 numbers
Test #24:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
0.64 0.67 2 74 42
output:
74 42
result:
ok 2 numbers
Test #25:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
0.65 0.56 2 94 96
output:
94 96
result:
ok 2 numbers
Test #26:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
0.65 0.90 10 97 23
output:
97 -61.70357628 47.19267542 -24.85797963 26.31572112 -5.26696294 20.2606231 8.429138366 23.71350072 23
result:
ok 10 numbers
Test #27:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
0.67 0.88 4 70 42
output:
70 0.5478215065 61.96704041 42
result:
ok 4 numbers
Test #28:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
0.69 0.39 10 2 27
output:
2 22.36590769 16.2124763 19.90931265 20.06029149 21.60623306 22.73181449 24.11138289 25.50226184 27
result:
ok 10 numbers
Test #29:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
0.69 0.57 4 88 47
output:
88 11.8436096 58.33209062 47
result:
ok 4 numbers
Test #30:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
0.71 0.89 8 4 41
output:
4 6.838890363 8.415612158 12.06169705 16.05369973 22.13303719 30.00224916 41
result:
ok 8 numbers
Test #31:
score: 0
Accepted
time: 0ms
memory: 3980kb
input:
0.72 0.49 8 21 48
output:
21 19.94044237 24.64711851 27.51674209 31.88914237 36.44338613 41.86491777 48
result:
ok 8 numbers
Test #32:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
0.74 0.58 3 57 29
output:
57 -5.486486486 29
result:
ok 3 numbers
Test #33:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
0.76 0.70 2 91 18
output:
91 18
result:
ok 2 numbers
Test #34:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
0.77 0.36 10 31 25
output:
31 5.214972085 15.17552851 13.5625469 15.90635137 17.13040744 18.91670023 20.73280585 22.77427259 25
result:
ok 10 numbers
Test #35:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
0.77 0.96 8 78 68
output:
78 -40.09755701 44.0048811 -4.609896277 38.69506573 25.36970018 56.68193224 68
result:
ok 8 numbers
Test #36:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
0.78 0.52 7 73 77
output:
73 8.727547506 44.76748705 39.45696461 54.05552566 62.68093161 77
result:
ok 7 numbers
Test #37:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
0.78 0.69 4 42 97
output:
42 57.29790511 73.67236599 97
result:
ok 4 numbers
Test #38:
score: 0
Accepted
time: 0ms
memory: 3972kb
input:
0.78 0.70 10 54 99
output:
54 -13.01288635 27.64994865 12.4579395 29.07215686 31.39684 44.840045 56.9530231 75.81138952 99
result:
ok 10 numbers
Test #39:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
0.78 0.76 10 97 83
output:
97 -43.73473696 39.60690517 -2.345014055 28.27213697 20.27005615 37.2974679 44.49726763 63.05394436 83
result:
ok 10 numbers
Test #40:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
0.78 0.95 10 100 32
output:
100 -63.26957882 45.64972852 -24.49931163 24.25777903 -4.353278407 19.64933292 11.19086519 27.39574112 32
result:
ok 10 numbers
Test #41:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
0.79 0.90 10 98 42
output:
98 -58.24691463 42.18493744 -19.09612258 22.88050686 0.8890900914 21.29483734 17.62310258 33.08760465 42
result:
ok 10 numbers
Test #42:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
0.81 0.48 10 97 1
output:
97 -38.25750168 15.57142364 -5.75074766 2.816177741 -0.4792549066 0.9635688414 0.5504484064 0.908376253 1
result:
ok 10 numbers
Test #43:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
0.81 0.86 10 20 100
output:
20 -3.33284287 14.50039728 8.879076925 19.66239397 23.56254527 35.99532048 49.41999852 70.98617441 100
result:
ok 10 numbers
Test #44:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
0.84 0.85 10 74 95
output:
74 -36.29080488 32.4157239 -3.617976067 24.51426542 17.5167033 35.55115638 44.75216916 67.81030502 95
result:
ok 10 numbers
Test #45:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
0.88 0.37 10 3 96
output:
3 29.02182849 26.64920907 34.18938052 39.94686222 47.80330955 56.84725142 67.71280578 80.62075211 96
result:
ok 10 numbers
Test #46:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
0.91 0.50 10 100 98
output:
100 -22.58685785 29.44595935 15.50239408 28.83015829 33.98664109 45.34292254 58.25538005 75.68385711 98
result:
ok 10 numbers
Test #47:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
0.94 0.48 10 44 97
output:
44 -1.582743439 19.63222117 17.69457105 26.05636294 32.98637527 43.51424697 56.73685228 74.21947969 97
result:
ok 10 numbers
Test #48:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
0.94 0.54 10 28 95
output:
28 0.4525463071 15.54539353 14.85704492 22.36013473 29.04133091 39.37332381 52.69324307 70.79324334 95
result:
ok 10 numbers
Test #49:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
0.95 0.57 10 2 94
output:
2 9.227284174 9.905919965 14.67017595 19.58304153 26.96588974 36.77992893 50.31148963 68.76047464 94
result:
ok 10 numbers
Test #50:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
0.98 0.90 10 21 99
output:
21 -8.213193485 10.85107038 3.242174841 12.94329469 15.60238615 26.93930365 40.44266512 63.8791851 99
result:
ok 10 numbers
Extra Test:
score: 0
Extra Test Passed