結果
問題 |
No.2970 三次関数の絶対値
|
ユーザー |
|
提出日時 | 2024-11-29 21:45:44 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 839 bytes |
コンパイル時間 | 4,947 ms |
コンパイル使用メモリ | 307,180 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-29 21:45:52 |
合計ジャッジ時間 | 6,039 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using mint = atcoder::static_modint<998244353>; //using mint = atcoder::static_modint<1000000007>; using namespace std; using namespace atcoder; using ld = long double; using ll = long long; #define mp(a,b) make_pair(a,b) #define rep(i,s,n) for(int i=s; i<n; i++) const vector<int> dx{1,0,-1,0},dy{0,1,0,-1}; double get(ld x,vector<ll>&c){ ld out=0; ld p=1; rep(i,0,4){ out+=p*c[i]; p*=x; } out=abs(out); return out; } int main(){ vector<ll> c(4);rep(i,0,4)cin >> c[i]; int l,r; cin >> l >> r; int m=1000000; double ans=1e18; rep(i,0,m+1){ ld x=l+(r-l)/(ld)m*i; ans=min(ans,get(x,c)); } // if(ans<1e-6){ // cout << 0; // } // else cout << setprecision(16)<< ans; printf("%f",ans); }