QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#516363#8795. Mysterious SequenceSocialPandaWA 0ms4100kbC++231.4kb2024-08-12 16:26:512024-08-12 16:26:52

Judging History

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

  • [2024-08-12 16:26:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4100kb
  • [2024-08-12 16:26:51]
  • 提交

answer

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
//#define int long long
//#define LL long long
#define double long double
//#define lf Lf
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define PII pair<int,int>
#define Gheap priority_queue<int,vector<int>,greater<int>>
#define Lheap priority_queue<int>
#define MAXN 0x3f3f3f3f
#define MINN -0x3f3f3f3f
using namespace std;
//const int N=1e6+100,M=2*N;
//int e[N],w[M],h[M],ne[M],idx;

double aa,bb,bg,ed;
double eps = 1e-8;
int n;

bool check(double num)
{
	double preB=bg;
	double preA=num;
	for(int i=3;i<=n;i++)
	{
		double newone = preA*aa+preB*bb;
		preB=preA;
		preA=newone;
	}
	if(preA-ed>eps) return false;
	else return true;
}

void solve()
{
	unordered_map<char,double> mp;
	cin>>aa>>bb>>n>>bg>>ed;

	double ll=-10.0,rr=10.0;

	while(rr-ll>eps)
	{
		double mid = (ll+rr)/2.0;
		if(check(mid)) ll=mid;
		else rr=mid;
	}

	printf("%.9Lf\n",bg);
	if(n>2)
	{
		printf("%.9Lf\n",ll);
		double preB=bg;
		double preA=ll;
		for(int i=3;i<n;i++)
		{
			double newone = preA*aa+preB*bb;
			preB=preA;
			preA=newone;
			printf("%.9Lf\n",newone);
		}
	}
	printf("%.9Lf\n",ed);
    
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int tt=1;
    //cin >> tt;
    while(tt--) solve();
}

详细

Test #1:

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

input:

1.0 1.0 10 1 10

output:

1.000000000
-0.323529420
0.676470580
0.352941159
1.029411739
1.382352898
2.411764637
3.794117535
6.205882171
10.000000000

result:

ok 10 numbers

Test #2:

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

input:

1 1 2 1 100

output:

1.000000000
100.000000000

result:

ok 2 numbers

Test #3:

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

input:

1 1 5 50 100

output:

50.000000000
0.000000000
50.000000000
50.000000000
100.000000000

result:

ok 5 numbers

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 4100kb

input:

0.25 0.25 10 1 1

output:

1.000000000
9.999999991
2.749999998
3.187499997
1.484374999
1.167968749
0.663085937
0.457763671
0.280212402
1.000000000

result:

wrong answer 2nd numbers differ - expected: '55.8755365', found: '10.0000000', error = '0.8210308'