結果
| 問題 |
No.2970 三次関数の絶対値
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-26 14:28:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,495 bytes |
| コンパイル時間 | 1,069 ms |
| コンパイル使用メモリ | 118,496 KB |
| 最終ジャッジ日時 | 2025-02-26 16:53:40 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 38 WA * 12 |
ソースコード
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <ctime>
#include <assert.h>
#include <deque>
#include <list>
#include <stack>
using namespace std;
#define is_mul_overflow(a, b) \
((b != 0) && (a > LLONG_MAX / b || a < LLONG_MIN / b))
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef pair<long long , long long> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<int, long long > pil;
typedef pair<long long, pii> plii;
typedef pair<double, int> pdi;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ull, ull> puu;
typedef long double ld;
const int N = 2000086, MOD = 998244353, INF = 0x3f3f3f3f, MID = 333;
const long double EPS = 1e-8;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
// int dx[8] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[8] = {1, 2, 2, 1, -1, -2, -2, -1};
int n, m, cnt;
int w[N];
vector<ll> num;
ll res;
ll lowbit(ll x) { return x & -x; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline double rand(double l, double r) { return (double)rand() / RAND_MAX * (r - l) + l; }
inline ll qmi(ll a, ll b, ll c) { ll res = 1; while (b) { if (b & 1) res = res * a % c; a = a * a % c; b >>= 1; } return res; }
inline ll qmi(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res *= a; a *= a; b >>= 1; } return res; }
inline double qmi(double a, ll b) { double res = 1; while (b) { if (b & 1) res *= a; a *= a; b >>= 1; } return res; }
// inline ll C(ll a, ll b) { if (a < b) return 0; if (b > a - b) b = a - b; ll res = 1; for (ll i = 1, j = a; i <= b; i++, j--) { res = res * (j % MOD) % MOD; res = res * qmi(i, MOD - 2, MOD) % MOD; } return res; }
inline ll C(ll a, ll b, int* c) { if (a < b) return 0; ll res = 1; for (ll j = a, i = 1; i < b + 1; i++, j--) res *= j; for (ll j = a, i = 1; i < b + 1; i++, j--) res /= i; return res; }
inline int find_(int x) { return lower_bound(num.begin(), num.end(), x) - num.begin(); }
int c0, c1, c2, c3, l, r;
int main() {
cin >> c0 >> c1 >> c2 >> c3 >> l >> r;
int lv = c0 + c1 * l + c2 * l * l + c3 * l * l * l;
int rv = c0 + c1 * r + c2 * r * r + c3 * r * r * r;
int a = 3 * c3, b = 2 * c2, c = c1;
if (b * b - 4 * a * c < 0) {
if (lv >= 0 && rv >= 0) puts("0.000000");
else if (lv <= 0 && rv <= 0) printf("%lf\n", (double)max(abs(lv), abs(rv)));
else puts("0.000000");
} else {
double x1 = (double)(-b + sqrt(b * b - 4 * a * c)) / (2 * a);
double x2 = (double)(-b - sqrt(b * b - 4 * a * c)) / (2 * a);
if (!c2 && !c3) x1 = x2 = l;
else if (!c3) x1 = x2 = -c1 / (2.0 * c2);
if (x1 >= l && x1 <= r) x1 = c0 + c1 * x1 + c2 * x1 * x1 + c3 * x1 * x1 * x1;
else x1 = 1e9;
if (x2 >= l && x2 <= r) x2 = c0 + c1 * x2 + c2 * x2 * x2 + c3 * x2 * x2 * x2;
else x2 = 1e9;
if (x1 >= 0 && x2 >= 0 && lv >= 0 && rv >= 0) printf("%lf\n", min({(double)lv, (double)rv, x2, x1}));
else if (x1 <= 0 && x2 <= 0 && lv <= 0 && rv <= 0) printf("%lf\n", -max({(double)lv, (double)rv, x2, x1}));
else puts("0.000000");
}
return 0;
}