QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#545174#8795. Mysterious SequenceSakib_Safwan#WA 0ms4020kbC++203.0kb2024-09-02 23:31:492024-09-02 23:31:50

Judging History

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

  • [2024-09-02 23:31:50]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4020kb
  • [2024-09-02 23:31:49]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;


typedef long long ll;
typedef long double ld;

#define endl "\n"
#define all(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
//#define int long long



// Don't Start typing till you complete the idea.


// Check these things for WA and before submitting
// 1. Did you clear all the global arrays
// 2. Did you checked your <= >= < > 
// 3. Did you take the input properly. Did you use break or return while taking input?
// 4. Did you divide by 0.
// 5. Check array , vector , etc size
// 6. in the while loop did you miss something that would cause infinite loop?
// 7. Did you save your dp?
// 8. Are you trying to use something after deleting it?
// 9. Did you read the problem statement wrong?
// 10. Did you check the constrains of the problem properly
// 11. Did you checked for smaller cases like 1 , 0 , etc
// 12. Is it something to with overflow?
// 13. Did you initialized all the variables properly?
// 14. Did you use the formulas correctly?

// STRESS TESTING !!!!!! STRESS TESTING !!!!!
// STRESS Testing Not working?
// Stress test for multiple cases? 
// Stress test for big inputs?
// Stress test for really small inputs?
// Even then if it doesn't work -> Did you wrote the wrong Brute force code


// Check these things if you are not generating ideas
// 1. Did you try thinking it in reverse?
// 2. Read the problem statement again
// 3. Check the constraints again
// 4. Try smaller cases in notebook and try to expand
// 5. Think about invariants
// 6. Think simpler ideas maybe?
// 7. Think brute force and try to get something out of it.
// 8. Maybe take a deep breath and take a break for few minutes and drink some water? :3 

const long double EPS = 1e-9;
void GG()
{
    long double a , b;
    cin >> a >> b;
    ll n , d , e;
    cin >> n >> d >> e;
    long double x1 = d , xn = e;
    long double l = -200;
    long double r = 200;
    long double mid;
    if(n == 2){
        cout << fixed << setprecision(7) << x1 << ' ' << xn << endl;
        return;
    }
    vector<long double> ans;
    auto check = [&]() -> int{
        ans.clear();
        ans.pb(x1);
        ans.pb(mid);
        for(int i = 3; i <= n; i++){
            ans.pb(a * ans[ans.size() - 1] + b * ans[ans.size() - 2]);
        }
        if(ans.back() - xn > EPS) return 0;
        else if(xn - ans.back() > EPS) return 1;
        return 2;
    };
    while(r - l > EPS){
        mid = (l + r) / 2;
        auto cmpr = check();
        if(cmpr == 0){
            r = mid;
        } 
        else if(cmpr == 1){
            l = mid;
        }
        else{
            l = r = mid;
        }
    }
    for(auto x : ans){
        cout << fixed << setprecision(8) << x << endl; 
    }
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int ttc=1;
	// cin>>ttc;
	//int cnt=0;
	while(ttc--)
	{
		//cout<<"Case "<<++cnt<<": ";
		GG();
	}
}

详细

Test #1:

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

input:

1.0 1.0 10 1 10

output:

1.00000000
-0.32352941
0.67647059
0.35294118
1.02941177
1.38235294
2.41176471
3.79411765
6.20588236
10.00000002

result:

ok 10 numbers

Test #2:

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

input:

1 1 2 1 100

output:

1.0000000 100.0000000

result:

ok 2 numbers

Test #3:

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

input:

1 1 5 50 100

output:

50.00000000
0.00000000
50.00000000
50.00000000
100.00000000

result:

ok 5 numbers

Test #4:

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

input:

0.25 0.25 10 1 1

output:

1.00000000
55.87553643
14.21888411
17.52360513
7.93562231
6.36480686
3.57510729
2.48497854
1.51502146
1.00000000

result:

ok 10 numbers

Test #5:

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

input:

0.25 0.63 6 93 12

output:

93.00000000
-14.20480796
55.03879801
4.81067049
35.87711037
12.00000000

result:

ok 6 numbers

Test #6:

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

input:

0.25 0.80 10 5 63

output:

5.00000000
78.76953618
23.69238405
68.93872496
36.18858848
64.19812708
45.00040255
62.60860231
51.65247262
63.00000000

result:

ok 10 numbers

Test #7:

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

input:

0.25 0.99 3 18 30

output:

18.00000000
48.72000000
30.00000000

result:

ok 3 numbers

Test #8:

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

input:

0.28 0.64 9 6 10

output:

6.00000000
20.95040335
9.70611294
16.12596977
10.72718381
13.32423212
10.59618263
11.49443969
10.00000000

result:

ok 9 numbers

Test #9:

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

input:

0.31 0.40 7 10 49

output:

10.00000000
200.00000000
66.00000000
100.46000000
57.54260000
58.02220600
41.00392386

result:

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