QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#436257#8795. Mysterious Sequenceucup-team3670#WA 1ms4000kbC++201.8kb2024-06-08 23:49:442024-06-08 23:49:45

Judging History

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

  • [2024-06-08 23:49:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4000kb
  • [2024-06-08 23:49:44]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

//#define MULTITEST

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef __float128 ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

int n;
long double a, b;
long double x1, xn;

bool read () {
	if (!(cin >> a >> b >> n >> x1 >> xn))
		return false;
	return true;
}

ld x[11];

ld f(ld m){
	x[0] = x1;
	x[1] = m;
	fore(i, 2, n) x[i] = x[i - 2] * a + x[i - 1] * b;
	return x[n - 1];
}

void solve() {
	ld l = -INF, r = INF;
	forn(_, 200){
		ld m = (l + r) / 2;
		if (f(m) > xn)
			r = m;
		else
			l = m;
	}
	f((l + r) / 2);
	forn(i, n) cout << (long double)x[i] << '\n';
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;
	cin.tie(0);
	ios::sync_with_stdio(false);

#ifdef MULTITEST
	int tc;
	cin >> tc;
	while(tc--){
		read();
#else
	while(read()) {	
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1.0 1.0 10 1 10

output:

1.000000000000000
-0.323529411764706
0.676470588235294
0.352941176470588
1.029411764705882
1.382352941176471
2.411764705882353
3.794117647058824
6.205882352941176
10.000000000000000

result:

ok 10 numbers

Test #2:

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

input:

1 1 2 1 100

output:

1.000000000000000
100.000000000000000

result:

ok 2 numbers

Test #3:

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

input:

1 1 5 50 100

output:

50.000000000000000
0.000000000000000
50.000000000000000
50.000000000000000
100.000000000000000

result:

ok 5 numbers

Test #4:

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

input:

0.25 0.25 10 1 1

output:

1.000000000000000
55.875536480686695
14.218884120171674
17.523605150214592
7.935622317596567
6.364806866952790
3.575107296137339
2.484978540772532
1.515021459227468
1.000000000000000

result:

ok 10 numbers

Test #5:

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

input:

0.25 0.63 6 93 12

output:

93.000000000000000
-2.196895156100696
21.865956051656561
13.226328523518460
13.799075982730770
12.000000000000000

result:

wrong answer 2nd numbers differ - expected: '-14.2048080', found: '-2.1968952', error = '0.8453414'