QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#435185 | #8795. Mysterious Sequence | ucup-team3792# | WA | 1ms | 4012kb | C++14 | 622b | 2024-06-08 19:14:09 | 2024-06-08 19:14:09 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
struct node{
double x,y;
node operator +(const node &b) const
{
return {x+b.x,y+b.y};
}
node operator *(const int &b) const
{
return {x*b,y*b};
}
}f[15];
double x1,xn,a,b;
double ans[15];
int n;
int main()
{
cin>>a>>b>>n>>x1>>xn;
f[1]={1,0};
f[2]={0,1};
for(int i=3;i<=n;i++)
{
f[i]=f[i-1]*a+f[i-2]*b;
// cerr<<f[i].x<<" "<<f[i].y<<"\n";
}
ans[1]=x1;
ans[n]=xn;
ans[2]=(ans[n]-f[n].x*x1)/f[n].y;
for(int i=3;i<=n;i++)
{
ans[i]=ans[i-1]*a+ans[i-2]*b;
}
for(int i=1;i<=n;i++)
{
printf("%.12lf\n",ans[i]);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3916kb
input:
1.0 1.0 10 1 10
output:
1.000000000000 -0.323529411765 0.676470588235 0.352941176471 1.029411764706 1.382352941176 2.411764705882 3.794117647059 6.205882352941 10.000000000000
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3940kb
input:
1 1 2 1 100
output:
1.000000000000 100.000000000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 1ms
memory: 4012kb
input:
1 1 5 50 100
output:
50.000000000000 0.000000000000 50.000000000000 50.000000000000 100.000000000000
result:
ok 5 numbers
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3968kb
input:
0.25 0.25 10 1 1
output:
1.000000000000 inf inf inf inf inf inf inf inf inf
result:
wrong output format Expected double, but "inf" found