QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#436797 | #8795. Mysterious Sequence | ucup-team1766# | WA | 1ms | 3924kb | C++14 | 2.8kb | 2024-06-09 03:12:21 | 2024-06-09 03:12:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// if you end up using long double, you need to set the floating point notation to fixed, and set the percision to be very high
typedef long double ld;
// contrsuct umaps like this, unordered_map<long long, int, custom_hash> safe_map;
// FIXED_RANDOM is static so it doesn not get redeclared between function calls
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
#define INF 2001001001
#define INF2 2e18
#define MOD 1000000007
#define f0r(a, b) for (long long a = 0; a < b; a++)
#define f1r(a, b, c) for(long long a = b; a < c; a++)
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define pf push_front
#define f first
#define s second
#define mp make_pair
#define pll pair<ll, ll>
#define pii pair<int, int>
#define tp make_tuple
// first four are north, west, east ,south
int dir1[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dir2[] = {0, 1, 0, -1, 1, -1, 1, -1};
int main() {
// apparently this does fast i/o
cin.tie(0) , ios::sync_with_stdio(0);
// use this if you read in from a file
/*
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
*/
stringstream ss;
// Do it once. Do it right.
// Read the problem statement carefully
// Plan out the steps in words on a piece of paper before implementing
// after RTE(obviously) but also WA, run valgrind!!!
cout << fixed << setprecision(8);
// if you use ld, use the above and don't use string stream
// use instead of ceil(a, b) if a and b are positive
// (a + b - 1) / b
double a, b;
int n;
double x1, xn;
cin >> a >> b;
cin >> n;
cin >> x1 >> xn;
if(n == 2){
cout << x1 << " " << xn << "\n";
return 0;
}
double fact1 = 1, fact2 = a, con1 = 0, con2 = b;
for(int i = 3; i < n; i++){
double temp1, temp2;
temp1 = a*fact2 + b*fact1;
temp2 = a*con2 + b*con1;
fact1 = fact2;
con1 = con2;
fact2 = temp1;
con2 = temp2;
}
double x2 = (xn-con2)/fact2;
vector<double> ans;
ans.pb(x1);
ans.pb(x2);
double curr2 = x2, curr1 = x1;
for(int i = 3; i < n; i++){
double temp = a*curr2 + b*curr1;
ans.pb(temp);
curr1 = curr2;
curr2 = temp;
}
ans.pb(xn);
for(auto d : ans){
cout << d << " ";
}
cout << endl;
cout << ss.str();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3872kb
input:
1.0 1.0 10 1 10
output:
1.00000000 -0.32352941 0.67647059 0.35294118 1.02941176 1.38235294 2.41176471 3.79411765 6.20588235 10.00000000
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3924kb
input:
1 1 2 1 100
output:
1.00000000 100.00000000
result:
ok 2 numbers
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3904kb
input:
1 1 5 50 100
output:
50.00000000 32.66666667 82.66666667 115.33333333 100.00000000
result:
wrong answer 2nd numbers differ - expected: '0.0000000', found: '32.6666667', error = '32.6666667'