QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#516365#8795. Mysterious SequenceSocialPandaWA 1ms4052kbC++231.4kb2024-08-12 16:27:562024-08-12 16:27:56

Judging History

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

  • [2024-08-12 16:27:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4052kb
  • [2024-08-12 16:27:56]
  • 提交

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=-200.0,rr=200.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();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1.0 1.0 10 1 10

output:

1.000000000
-0.323529413
0.676470587
0.352941173
1.029411760
1.382352933
2.411764693
3.794117625
6.205882318
10.000000000

result:

ok 10 numbers

Test #2:

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

input:

1 1 2 1 100

output:

1.000000000
100.000000000

result:

ok 2 numbers

Test #3:

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

input:

1 1 5 50 100

output:

50.000000000
0.000000000
50.000000000
50.000000000
100.000000000

result:

ok 5 numbers

Test #4:

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

input:

0.25 0.25 10 1 1

output:

1.000000000
55.875537038
14.218884260
17.523605324
7.935622396
6.364806930
3.575107332
2.484978565
1.515021474
1.000000000

result:

ok 10 numbers

Test #5:

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

input:

0.25 0.63 6 93 12

output:

93.000000000
-14.204807940
55.038798015
4.810670501
35.877110375
12.000000000

result:

ok 6 numbers

Test #6:

score: 0
Accepted
time: 1ms
memory: 3764kb

input:

0.25 0.80 10 5 63

output:

5.000000000
78.769536194
23.692384049
68.938724967
36.188588481
64.198127094
45.000402558
62.608602315
51.652472625
63.000000000

result:

ok 10 numbers

Test #7:

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

input:

0.25 0.99 3 18 30

output:

18.000000000
48.720000038
30.000000000

result:

ok 3 numbers

Test #8:

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

input:

0.28 0.64 9 6 10

output:

6.000000000
20.950403373
9.706112944
16.125969783
10.727183824
13.324232132
10.596182644
11.494439705
10.000000000

result:

ok 9 numbers

Test #9:

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

input:

0.31 0.40 7 10 49

output:

10.000000000
199.999999994
65.999999998
100.459999997
57.542599998
58.022205998
49.000000000

result:

wrong answer 2nd numbers differ - expected: '240.1150640', found: '200.0000000', error = '0.1670660'