QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#516346#8795. Mysterious SequenceSocialPandaWA 0ms3768kbC++231.5kb2024-08-12 16:18:442024-08-12 16:18:45

Judging History

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

  • [2024-08-12 16:18:45]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3768kb
  • [2024-08-12 16:18:44]
  • 提交

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;
	}

	cout<<bg<<endl;
	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);
	}
	cout<<ed<<endl;
    
}

int main()
{
    //std::ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int tt=1;
    //cin >> tt;
    while(tt--) solve();
}
/*
1.00 //1
? //2
1*B+?*A //3
?*B+(1*B+?*A)*A  //4*
(?*B+(1*B+?*A)*A)*B+ (1*B+?*A)*A  //5

?A*LB*+A*?B*+



10.00
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3768kb

input:

1.0 1.0 10 1 10

output:

1
0.676470580
0.352941159
1.029411739
1.382352898
2.411764637
3.794117535
6.205882171
10

result:

wrong answer 2nd numbers differ - expected: '-0.3235294', found: '0.6764706', error = '1.0000000'