QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#436177 | #8795. Mysterious Sequence | ucup-team3670# | WA | 0ms | 4056kb | C++17 | 1.9kb | 2024-06-08 23:32:46 | 2024-06-08 23:32:46 |
Judging History
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 long double 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);
ld a, b;
int n, x1, xn;
bool read () {
string A, B;
if (!(cin >> A >> B >> n >> x1 >> xn))
return false;
a = stold(A.c_str());
b = stold(B.c_str());
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 << 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
if(read()) {
#endif
solve();
#ifdef _DEBUG
cerr << "TIME = " << clock() - tt << endl;
tt = clock();
#endif
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3896kb
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: 0ms
memory: 3988kb
input:
1 1 2 1 100
output:
1.000000000000000 100.000000000000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3892kb
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: 0ms
memory: 4056kb
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: 3832kb
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'