QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#440231 | #8795. Mysterious Sequence | pengpeng_fudan# | AC ✓ | 1ms | 4020kb | C++23 | 648b | 2024-06-13 13:22:08 | 2024-06-13 13:22:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
using ll=long long;
double a,b,x1,xn;
int n;
double x[20];
double f(double x2){
x[1]=x1;x[2]=x2;
for(int i=3;i<=n;i++)x[i]=a*x[i-1]+b*x[i-2];
return x[n];
}
void solve() {
cin>>a>>b>>n>>x1>>xn;
double l=-1e9,r=1e9;
while(abs(x[n]-xn)>1e-9){
double m=(l+r)/2;
double t=f(m);
if(t>xn)r=m;
else l=m;
}
for(int i=1;i<=n;i++)printf("%.10f\n",x[i]);
}
int main() {
// ios::sync_with_stdio(0),cin.tie(0);
int _ = 1;
// cin >> _;
while(_--) solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3820kb
input:
1.0 1.0 10 1 10
output:
1.0000000000 -0.3235294118 0.6764705882 0.3529411765 1.0294117647 1.3823529412 2.4117647059 3.7941176472 6.2058823531 10.0000000003
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
1 1 2 1 100
output:
1.0000000000 99.9999999994
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
1 1 5 50 100
output:
50.0000000000 0.0000000000 50.0000000000 50.0000000000 100.0000000000
result:
ok 5 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3976kb
input:
0.25 0.25 10 1 1
output:
1.0000000000 55.8755365310 14.2188841327 17.5236051659 7.9356223247 6.3648068726 3.5751072993 2.4849785430 1.5150214606 1.0000000009
result:
ok 10 numbers
Test #5:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
0.25 0.63 6 93 12
output:
93.0000000000 -14.2048079584 55.0387980104 4.8106704888 35.8771103688 12.0000000002
result:
ok 6 numbers
Test #6:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
0.25 0.80 10 5 63
output:
5.0000000000 78.7695361836 23.6923840459 68.9387249584 36.1885884763 64.1981270858 45.0004025525 62.6086023067 51.6524726187 63.0000000001
result:
ok 10 numbers
Test #7:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
0.25 0.99 3 18 30
output:
18.0000000000 48.7199999996 29.9999999999
result:
ok 3 numbers
Test #8:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
0.28 0.64 9 6 10
output:
6.0000000000 20.9504033497 9.7061129379 16.1259697664 10.7271838148 13.3242321186 10.5961826347 11.4944396937 10.0000000004
result:
ok 9 numbers
Test #9:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
0.31 0.40 7 10 49
output:
10.0000000000 240.1150639986 78.4356698396 120.3610832497 68.6862037432 69.4371564603 49.0000000000
result:
ok 7 numbers
Test #10:
score: 0
Accepted
time: 0ms
memory: 3976kb
input:
0.32 0.28 5 36 6
output:
36.0000000000 10.1213768131 13.3188405802 7.0960144933 6.0000000003
result:
ok 5 numbers
Test #11:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
0.35 0.65 10 86 82
output:
86.0000000000 79.5339247864 83.7368736752 81.0049568975 82.7807028030 81.6264679644 82.3767206095 81.8890563902 82.2060381327 82.0000000001
result:
ok 10 numbers
Test #12:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
0.36 0.68 8 72 59
output:
72.0000000000 38.2399186413 62.7263707109 48.5846381320 60.1444018109 54.6895385817 60.5864271208 58.9999999991
result:
ok 8 numbers
Test #13:
score: 0
Accepted
time: 0ms
memory: 4012kb
input:
0.43 0.61 2 93 84
output:
93.0000000000 84.0000000009
result:
ok 2 numbers
Test #14:
score: 0
Accepted
time: 0ms
memory: 3964kb
input:
0.46 0.96 6 65 35
output:
65.0000000000 -16.6174236628 54.7559851151 9.2350264367 56.8138578714 35.0000000000
result:
ok 6 numbers
Test #15:
score: 0
Accepted
time: 0ms
memory: 3940kb
input:
0.50 0.90 4 19 1
output:
19.0000000000 -6.5652173906 13.8173913047 1.0000000009
result:
ok 4 numbers
Test #16:
score: 0
Accepted
time: 1ms
memory: 3824kb
input:
0.54 0.35 3 16 22
output:
16.0000000000 30.3703703713 22.0000000005
result:
ok 3 numbers
Test #17:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
0.55 0.89 10 74 13
output:
74.0000000000 -48.3219370767 39.2829346078 -21.4009099640 23.1913113208 -6.2915886415 17.1798933226 3.8494274365 17.4072901472 12.9999999995
result:
ok 10 numbers
Test #18:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
0.56 0.36 3 31 88
output:
31.0000000000 137.2142857149 88.0000000004
result:
ok 3 numbers
Test #19:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
0.57 0.93 7 71 48
output:
71.0000000000 -34.0805653620 46.6040777437 -5.1306014728 40.4173494621 18.2664298237 47.9999999993
result:
ok 7 numbers
Test #20:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
0.58 0.41 8 30 69
output:
30.0000000000 89.4321216839 64.1706305767 73.8861356249 69.1639171989 70.4083875815 69.1940708488 69.0000000007
result:
ok 8 numbers
Test #21:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
0.58 0.49 6 31 96
output:
31.0000000000 99.5576135386 72.9334158524 91.0846118283 88.5664486281 96.0000000002
result:
ok 6 numbers
Test #22:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
0.61 0.29 8 62 25
output:
62.0000000000 34.4076512560 38.9686672661 33.7491058966 31.8878681041 29.2388402535 27.0831743048 24.9999999995
result:
ok 8 numbers
Test #23:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
0.63 0.89 9 37 85
output:
37.0000000000 -5.8878533021 29.2206524197 13.1688215855 34.3027382523 33.3309763101 51.5279521199 62.1271787515 85.0000000002
result:
ok 9 numbers
Test #24:
score: 0
Accepted
time: 1ms
memory: 4012kb
input:
0.64 0.67 2 74 42
output:
74.0000000000 42.0000000004
result:
ok 2 numbers
Test #25:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
0.65 0.56 2 94 96
output:
94.0000000000 95.9999999998
result:
ok 2 numbers
Test #26:
score: 0
Accepted
time: 0ms
memory: 4020kb
input:
0.65 0.90 10 97 23
output:
97.0000000000 -61.7035762793 47.1926754185 -24.8579796293 26.3157211176 -5.2669629400 20.2606230949 8.4291383657 23.7135007231 22.9999999991
result:
ok 10 numbers
Test #27:
score: 0
Accepted
time: 1ms
memory: 3964kb
input:
0.67 0.88 4 70 42
output:
70.0000000000 0.5478215069 61.9670404096 42.0000000005
result:
ok 4 numbers
Test #28:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
0.69 0.39 10 2 27
output:
2.0000000000 22.3659076867 16.2124763038 19.9093126474 20.0602914852 21.6062330573 22.7318144887 24.1113828896 25.5022618444 26.9999999996
result:
ok 10 numbers
Test #29:
score: 0
Accepted
time: 1ms
memory: 3868kb
input:
0.69 0.57 4 88 47
output:
88.0000000000 11.8436095983 58.3320906228 47.0000000007
result:
ok 4 numbers
Test #30:
score: 0
Accepted
time: 1ms
memory: 3976kb
input:
0.71 0.89 8 4 41
output:
4.0000000000 6.8388903629 8.4156121576 12.0616970549 16.0536997293 22.1330371866 30.0022491615 41.0000000008
result:
ok 8 numbers
Test #31:
score: 0
Accepted
time: 1ms
memory: 3824kb
input:
0.72 0.49 8 21 48
output:
21.0000000000 19.9404423702 24.6471185066 27.5167420861 31.8891423702 36.4433861288 41.8649177741 48.0000000005
result:
ok 8 numbers
Test #32:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
0.74 0.58 3 57 29
output:
57.0000000000 -5.4864864873 28.9999999994
result:
ok 3 numbers
Test #33:
score: 0
Accepted
time: 1ms
memory: 3816kb
input:
0.76 0.70 2 91 18
output:
91.0000000000 18.0000000009
result:
ok 2 numbers
Test #34:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
0.77 0.36 10 31 25
output:
31.0000000000 5.2149720852 15.1755285056 13.5625469000 15.9063513751 17.1304074428 18.9167002260 20.7328058534 22.7742725885 25.0000000004
result:
ok 10 numbers
Test #35:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
0.77 0.96 8 78 68
output:
78.0000000000 -40.0975570076 44.0048811042 -4.6098962771 38.6950657266 25.3697001835 56.6819322389 68.0000000001
result:
ok 8 numbers
Test #36:
score: 0
Accepted
time: 0ms
memory: 4016kb
input:
0.78 0.52 7 73 77
output:
73.0000000000 8.7275475059 44.7674870546 39.4569646056 54.0555256608 62.6809316103 76.9999999997
result:
ok 7 numbers
Test #37:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
0.78 0.69 4 42 97
output:
42.0000000000 57.2979051133 73.6723659883 96.9999999991
result:
ok 4 numbers
Test #38:
score: 0
Accepted
time: 1ms
memory: 3912kb
input:
0.78 0.70 10 54 99
output:
54.0000000000 -13.0128863509 27.6499486463 12.4579394984 29.0721568612 31.3968400006 44.8400450033 56.9530231030 75.8113895226 98.9999999998
result:
ok 10 numbers
Test #39:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
0.78 0.76 10 97 83
output:
97.0000000000 -43.7347369591 39.6069051719 -2.3450140549 28.2721369678 20.2700561532 37.2974678951 44.4972676346 63.0539443552 82.9999999994
result:
ok 10 numbers
Test #40:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
0.78 0.95 10 100 32
output:
100.0000000000 -63.2695788174 45.6497285224 -24.4993116290 24.2577790257 -4.3532784076 19.6493329165 11.1908651876 27.3957411170 31.9999999995
result:
ok 10 numbers
Test #41:
score: 0
Accepted
time: 0ms
memory: 4020kb
input:
0.79 0.90 10 98 42
output:
98.0000000000 -58.2469146281 42.1849374438 -19.0961225847 22.8805068575 0.8890900912 21.2948373438 17.6231025837 33.0876046505 41.9999999992
result:
ok 10 numbers
Test #42:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
0.81 0.48 10 97 1
output:
97.0000000000 -38.2575016814 15.5714236381 -5.7507476602 2.8161777415 -0.4792549063 0.9635688418 0.5504484069 0.9083762536 1.0000000007
result:
ok 10 numbers
Test #43:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
0.81 0.86 10 20 100
output:
20.0000000000 -3.3328428696 14.5003972756 8.8790769254 19.6623939665 23.5625452687 35.9953204789 49.4199985190 70.9861744122 100.0000000002
result:
ok 10 numbers
Test #44:
score: 0
Accepted
time: 0ms
memory: 4012kb
input:
0.84 0.85 10 74 95
output:
74.0000000000 -36.2908048771 32.4157239033 -3.6179760667 24.5142654217 17.5167032975 35.5511563784 44.7521691607 67.8103050166 95.0000000005
result:
ok 10 numbers
Test #45:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
0.88 0.37 10 3 96
output:
3.0000000000 29.0218284903 26.6492090715 34.1893805243 39.9468622178 47.8033095457 56.8472514208 67.7128057822 80.6207521141 95.9999999998
result:
ok 10 numbers
Test #46:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
0.91 0.50 10 100 98
output:
100.0000000000 -22.5868578545 29.4459593524 15.5023940834 28.8301582921 33.9866410875 45.3429225356 58.2553800512 75.6838571144 97.9999999996
result:
ok 10 numbers
Test #47:
score: 0
Accepted
time: 0ms
memory: 3976kb
input:
0.94 0.48 10 44 97
output:
44.0000000000 -1.5827434387 19.6322211676 17.6945710470 26.0563629446 32.9863752705 43.5142469677 56.7368522795 74.2194796872 97.0000000001
result:
ok 10 numbers
Test #48:
score: 0
Accepted
time: 0ms
memory: 3932kb
input:
0.94 0.54 10 28 95
output:
28.0000000000 0.4525463071 15.5453935286 14.8570449227 22.3601347328 29.0413309072 39.3733238085 52.6932430698 70.7932433422 94.9999999994
result:
ok 10 numbers
Test #49:
score: 0
Accepted
time: 0ms
memory: 3932kb
input:
0.95 0.57 10 2 94
output:
2.0000000000 9.2272841742 9.9059199654 14.6701759464 19.5830415294 26.9658897424 36.7799289271 50.3114896339 68.7604746406 93.9999999999
result:
ok 10 numbers
Test #50:
score: 0
Accepted
time: 0ms
memory: 3932kb
input:
0.98 0.90 10 21 99
output:
21.0000000000 -8.2131934850 10.8510703847 3.2421748406 12.9432946900 15.6023861527 26.9393036507 40.4426651151 63.8791850985 99.0000000001
result:
ok 10 numbers
Extra Test:
score: 0
Extra Test Passed