QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#455400#8795. Mysterious Sequencemendicillin2#TL 0ms3920kbC++17834b2024-06-26 13:21:582024-06-26 13:21:59

Judging History

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

  • [2024-06-26 13:21:59]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3920kb
  • [2024-06-26 13:21:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c<'0' || c>'9')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0' && c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}

long double a[15];

const long double eps=1e-15;

int main()
{
	double A,B;
	cin>>A>>B;
	int n=read();
	a[1]=read(); int x=read();
	if(n==2) 
	{
		cout<<a[1]<<endl;
		cout<<x<<endl;
		return 0;
	}
	double lef=-1e9;
	double rig=1e9;
	while(rig-lef>eps)
	{
		long double mid=(lef+rig)/2.0;
		a[2]=mid;
		for(int i=3;i<=n;i++) 
		{
			a[i]=A*a[i-1]+B*a[i-2];
		}
		if(a[n]>x) rig=mid;
		else lef=mid;
	}
	a[2]=(lef+rig)/2;
	for(int i=3;i<=n;i++) 
	{
		a[i]=A*a[i-1]+B*a[i-2];
	}
	for(int i=1;i<=n;i++) printf("%.15Lf\n",a[i]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1.0 1.0 10 1 10

output:

1.000000000000000
-0.323529411764706
0.676470588235294
0.352941176470589
1.029411764705883
1.382352941176472
2.411764705882356
3.794117647058828
6.205882352941184
10.000000000000013

result:

ok 10 numbers

Test #2:

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

input:

1 1 2 1 100

output:

1
100

result:

ok 2 numbers

Test #3:

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

input:

1 1 5 50 100

output:

50.000000000000000
0.000000000000000
50.000000000000000
50.000000000000001
100.000000000000001

result:

ok 5 numbers

Test #4:

score: -100
Time Limit Exceeded

input:

0.25 0.25 10 1 1

output:


result: