| #include <bits/stdc++.h> | |
| #define alive std::cout << "$LINE @" << __LINE__ << " ALIVE" << std::endl | |
| #define watch(var) std::cout << "$ LINE @" << __LINE__ << " FUN @" << __FUNCTION__ \ | |
| << " VAR @" << (#var) << ": " << (var) << std::endl | |
| using namespace std; | |
| typedef int i32; | |
| typedef unsigned int u32; | |
| typedef long long i64; | |
| typedef unsigned long long u64; | |
| typedef double f64; | |
| typedef long double f128; | |
| typedef pair<int, int> pii; | |
| template <typename Tp> | |
| inline void read(Tp &x) | |
| { | |
| x = 0; | |
| bool neg = false; | |
| char c = getchar(); | |
| for (; !isdigit(c); c = getchar()) | |
| { | |
| if (c == '-') | |
| { | |
| neg = true; | |
| } | |
| } | |
| for (; isdigit(c); c = getchar()) | |
| { | |
| x = x * 10 + c - '0'; | |
| } | |
| if (neg) | |
| { | |
| x = -x; | |
| } | |
| } | |
| int main() | |
| { | |
| int p, a, b, c, d, n; | |
| auto price = [&](const int &k) { | |
| return (f64)p * (sin((f64)a * (f64)k + (f64)b) + | |
| cos((f64)c * (f64)k + (f64)d) + | |
| 2.0); | |
| }; | |
| read(p), read(a), read(b), read(c), read(d), read(n); | |
| f64 max, cur, ans = 0.0; | |
| max = price(1); | |
| for (int i = 2; i <= n; ++i) | |
| { | |
| cur = price(i); | |
| if (cur > max) | |
| { | |
| max = cur; | |
| } | |
| else | |
| { | |
| ans = std::max(ans, max - cur); | |
| } | |
| } | |
| printf("%.8f\n", ans); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment