I need a plan to improve myself in DP as i think this topic is hard to me and don't know the main idea of it and when we use DP in general.
| № | Пользователь | Рейтинг |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3603 |
| 4 | jiangly | 3583 |
| 5 | strapple | 3515 |
| 6 | tourist | 3470 |
| 7 | dXqwq | 3436 |
| 8 | Radewoosh | 3415 |
| 9 | Otomachi_Una | 3413 |
| 10 | Um_nik | 3376 |
| Страны | Города | Организации | Всё → |
| № | Пользователь | Вклад |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | adamant | 152 |
| 3 | Um_nik | 146 |
| 4 | Dominater069 | 144 |
| 5 | errorgorn | 141 |
| 6 | cry | 139 |
| 7 | Proof_by_QED | 136 |
| 8 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 9 | TheScrasse | 134 |
I need a plan to improve myself in DP as i think this topic is hard to me and don't know the main idea of it and when we use DP in general.
I will brute force in value where i will make ternary search on each value of a, b, c then take the max area. The problem is when i add value from range [0:k] to any side, This may result that the triangle isn't right.
long double f(long double a, long double b, long double c){
if((a + b) <= c || (a + c) <= b || (b + c) <= a) return NINF;
long double s = ((a + b + c) / 2);
return sqrt(s * (s - a) * (s - b) * (s - c));
}
long double ts(long double a, long double b, long double c, long double k){
long double l = 0, r = k;
long double maxVal = 0;
while(r - l > 1e-9){
long double mid = ((l + r) / 2);
if(f(a + mid, b, c) < f(a + mid + 1e-7, b, c)){
l = mid;
}else{
r = mid;
}
}
return f(a + r, b, c);
}
void solve(){
long double a, b, c, k;
read(a, b, c, k);
cout << setprecision(10) << max({ts(a, b, c, k), ts(b, a, c, k), ts(c, a, b, k)}) << "\n";
}
| Название |
|---|


