QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#500964 | #8795. Mysterious Sequence | ydzr00000 | AC ✓ | 0ms | 3952kb | C++20 | 870b | 2024-08-02 08:19:30 | 2024-08-02 08:19:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const double eps=1e-9;
double X[11];
int main(){
double a,b,x2=0;
int n,x1,xn;
scanf("%lf %lf %d %d %d",&a,&b,&n,&x1,&xn);
if(n>=3)
{
double l=-1e9,r=1e9;
auto check=[&](double val)->bool
{
X[1]=x1;X[2]=val;
for(int i=3;i<=n;i++)
X[i]=a*X[i-1]+b*X[i-2];
return X[n]-xn<=eps;
};
for(int i=1;i<=120;i++)
{
double mid=(l+r)/2;
if(check(mid))
{
x2=mid;
l=mid;
}
else
r=mid;
}
}
else
x2=xn;
X[1]=x1;X[2]=x2;
for(int i=3;i<=n;i++)
X[i]=a*X[i-1]+b*X[i-2];
for(int i=1;i<=n;i++)
printf("%.9lf\n",X[i]);
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3884kb
input:
1.0 1.0 10 1 10
output:
1.000000000 -0.323529412 0.676470588 0.352941177 1.029411765 1.382352941 2.411764706 3.794117647 6.205882354 10.000000001
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
1 1 2 1 100
output:
1.000000000 100.000000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
1 1 5 50 100
output:
50.000000000 0.000000000 50.000000000 50.000000001 100.000000001
result:
ok 5 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
0.25 0.25 10 1 1
output:
1.000000000 55.875536537 14.218884134 17.523605168 7.935622326 6.364806873 3.575107300 2.484978543 1.515021461 1.000000001
result:
ok 10 numbers
Test #5:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
0.25 0.63 6 93 12
output:
93.000000000 -14.204807957 55.038798011 4.810670490 35.877110369 12.000000001
result:
ok 6 numbers
Test #6:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
0.25 0.80 10 5 63
output:
5.000000000 78.769536185 23.692384046 68.938724959 36.188588477 64.198127087 45.000402553 62.608602308 51.652472619 63.000000001
result:
ok 10 numbers
Test #7:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
0.25 0.99 3 18 30
output:
18.000000000 48.720000004 30.000000001
result:
ok 3 numbers
Test #8:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
0.28 0.64 9 6 10
output:
6.000000000 20.950403351 9.706112938 16.125969767 10.727183815 13.324232119 10.596182635 11.494439694 10.000000001
result:
ok 9 numbers
Test #9:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
0.31 0.40 7 10 49
output:
10.000000000 240.115064004 78.435669841 120.361083252 68.686203745 69.437156462 49.000000001
result:
ok 7 numbers
Test #10:
score: 0
Accepted
time: 0ms
memory: 3952kb
input:
0.32 0.28 5 36 6
output:
36.000000000 10.121376816 13.318840581 7.096014495 6.000000001
result:
ok 5 numbers
Test #11:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
0.35 0.65 10 86 82
output:
86.000000000 79.533924788 83.736873676 81.004956899 82.780702804 81.626467965 82.376720610 81.889056391 82.206038134 82.000000001
result:
ok 10 numbers
Test #12:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
0.36 0.68 8 72 59
output:
72.000000000 38.239918644 62.726370712 48.584638134 60.144401812 54.689538584 60.586427123 59.000000001
result:
ok 8 numbers
Test #13:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
0.43 0.61 2 93 84
output:
93.000000000 84.000000000
result:
ok 2 numbers
Test #14:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
0.46 0.96 6 65 35
output:
65.000000000 -16.617423662 54.755985115 9.235026437 56.813857872 35.000000001
result:
ok 6 numbers
Test #15:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
0.50 0.90 4 19 1
output:
19.000000000 -6.565217390 13.817391305 1.000000001
result:
ok 4 numbers
Test #16:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
0.54 0.35 3 16 22
output:
16.000000000 30.370370372 22.000000001
result:
ok 3 numbers
Test #17:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
0.55 0.89 10 74 13
output:
74.000000000 -48.321937076 39.282934608 -21.400909964 23.191311321 -6.291588641 17.179893323 3.849427437 17.407290148 13.000000001
result:
ok 10 numbers
Test #18:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
0.56 0.36 3 31 88
output:
31.000000000 137.214285716 88.000000001
result:
ok 3 numbers
Test #19:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
0.57 0.93 7 71 48
output:
71.000000000 -34.080565361 46.604077744 -5.130601472 40.417349463 18.266429825 48.000000001
result:
ok 7 numbers
Test #20:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
0.58 0.41 8 30 69
output:
30.000000000 89.432121684 64.170630577 73.886135625 69.163917199 70.408387582 69.194070849 69.000000001
result:
ok 8 numbers
Test #21:
score: 0
Accepted
time: 0ms
memory: 3952kb
input:
0.58 0.49 6 31 96
output:
31.000000000 99.557613540 72.933415853 91.084611829 88.566448629 96.000000001
result:
ok 6 numbers
Test #22:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
0.61 0.29 8 62 25
output:
62.000000000 34.407651259 38.968667268 33.749105899 31.887868106 29.238840255 27.083174306 25.000000001
result:
ok 8 numbers
Test #23:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
0.63 0.89 9 37 85
output:
37.000000000 -5.887853302 29.220652420 13.168821586 34.302738253 33.330976310 51.527952120 62.127178752 85.000000001
result:
ok 9 numbers
Test #24:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
0.64 0.67 2 74 42
output:
74.000000000 42.000000000
result:
ok 2 numbers
Test #25:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
0.65 0.56 2 94 96
output:
94.000000000 96.000000000
result:
ok 2 numbers
Test #26:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
0.65 0.90 10 97 23
output:
97.000000000 -61.703576279 47.192675419 -24.857979629 26.315721118 -5.266962939 20.260623096 8.429138367 23.713500724 23.000000001
result:
ok 10 numbers
Test #27:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
0.67 0.88 4 70 42
output:
70.000000000 0.547821507 61.967040410 42.000000001
result:
ok 4 numbers
Test #28:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
0.69 0.39 10 2 27
output:
2.000000000 22.365907688 16.212476305 19.909312648 20.060291486 21.606233058 22.731814490 24.111382891 25.502261846 27.000000001
result:
ok 10 numbers
Test #29:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
0.69 0.57 4 88 47
output:
88.000000000 11.843609599 58.332090623 47.000000001
result:
ok 4 numbers
Test #30:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
0.71 0.89 8 4 41
output:
4.000000000 6.838890363 8.415612158 12.061697055 16.053699729 22.133037187 30.002249162 41.000000001
result:
ok 8 numbers
Test #31:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
0.72 0.49 8 21 48
output:
21.000000000 19.940442371 24.647118507 27.516742086 31.889142371 36.443386129 41.864917775 48.000000001
result:
ok 8 numbers
Test #32:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
0.74 0.58 3 57 29
output:
57.000000000 -5.486486485 29.000000001
result:
ok 3 numbers
Test #33:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
0.76 0.70 2 91 18
output:
91.000000000 18.000000000
result:
ok 2 numbers
Test #34:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
0.77 0.36 10 31 25
output:
31.000000000 5.214972086 15.175528506 13.562546900 15.906351375 17.130407443 18.916700226 20.732805854 22.774272589 25.000000001
result:
ok 10 numbers
Test #35:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
0.77 0.96 8 78 68
output:
78.000000000 -40.097557007 44.004881104 -4.609896277 38.695065727 25.369700184 56.681932239 68.000000001
result:
ok 8 numbers
Test #36:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
0.78 0.52 7 73 77
output:
73.000000000 8.727547507 44.767487055 39.456964606 54.055525662 62.680931611 77.000000001
result:
ok 7 numbers
Test #37:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
0.78 0.69 4 42 97
output:
42.000000000 57.297905115 73.672365990 97.000000001
result:
ok 4 numbers
Test #38:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
0.78 0.70 10 54 99
output:
54.000000000 -13.012886351 27.649948646 12.457939499 29.072156861 31.396840001 44.840045004 56.953023104 75.811389524 99.000000001
result:
ok 10 numbers
Test #39:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
0.78 0.76 10 97 83
output:
97.000000000 -43.734736959 39.606905172 -2.345014055 28.272136968 20.270056154 37.297467896 44.497267635 63.053944356 83.000000001
result:
ok 10 numbers
Test #40:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
0.78 0.95 10 100 32
output:
100.000000000 -63.269578817 45.649728523 -24.499311629 24.257779026 -4.353278407 19.649332917 11.190865188 27.395741118 32.000000001
result:
ok 10 numbers
Test #41:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
0.79 0.90 10 98 42
output:
98.000000000 -58.246914628 42.184937444 -19.096122584 22.880506858 0.889090092 21.294837344 17.623102585 33.087604652 42.000000001
result:
ok 10 numbers
Test #42:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
0.81 0.48 10 97 1
output:
97.000000000 -38.257501681 15.571423638 -5.750747660 2.816177742 -0.479254906 0.963568842 0.550448407 0.908376254 1.000000001
result:
ok 10 numbers
Test #43:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
0.81 0.86 10 20 100
output:
20.000000000 -3.332842870 14.500397276 8.879076925 19.662393967 23.562545269 35.995320479 49.419998519 70.986174413 100.000000001
result:
ok 10 numbers
Test #44:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
0.84 0.85 10 74 95
output:
74.000000000 -36.290804877 32.415723903 -3.617976067 24.514265422 17.516703298 35.551156379 44.752169161 67.810305017 95.000000001
result:
ok 10 numbers
Test #45:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
0.88 0.37 10 3 96
output:
3.000000000 29.021828491 26.649209072 34.189380525 39.946862218 47.803309546 56.847251422 67.712805783 80.620752115 96.000000001
result:
ok 10 numbers
Test #46:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
0.91 0.50 10 100 98
output:
100.000000000 -22.586857854 29.445959353 15.502394084 28.830158292 33.986641088 45.342922536 58.255380052 75.683857115 98.000000001
result:
ok 10 numbers
Test #47:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
0.94 0.48 10 44 97
output:
44.000000000 -1.582743439 19.632221168 17.694571047 26.056362945 32.986375271 43.514246968 56.736852280 74.219479688 97.000000001
result:
ok 10 numbers
Test #48:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
0.94 0.54 10 28 95
output:
28.000000000 0.452546307 15.545393529 14.857044923 22.360134733 29.041330908 39.373323809 52.693243071 70.793243343 95.000000001
result:
ok 10 numbers
Test #49:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
0.95 0.57 10 2 94
output:
2.000000000 9.227284174 9.905919966 14.670175947 19.583041530 26.965889743 36.779928927 50.311489634 68.760474641 94.000000001
result:
ok 10 numbers
Test #50:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
0.98 0.90 10 21 99
output:
21.000000000 -8.213193485 10.851070385 3.242174841 12.943294690 15.602386153 26.939303651 40.442665116 63.879185099 99.000000001
result:
ok 10 numbers
Extra Test:
score: 0
Extra Test Passed