惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
罗磊的独立博客
J
Java Code Geeks
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
The GitHub Blog
The GitHub Blog
G
Google Developers Blog
U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
Jina AI
Jina AI
F
Fortinet All Blogs
H
Help Net Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Last Week in AI
Last Week in AI
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
C
Check Point Blog
GbyAI
GbyAI

某岛

AtCoder Beginner Contest 409 Luogu P5325. 【模板】Min_25 筛 UOJ #188. 【UR #13】Sanrd AtCoder Beginner Contest 371 AtCoder Beginner Contest 369 RPGMaker 2k3 百科 OneShot 的考古 2024“开创拓芯”游戏创享节的相关记录 CJ 回来后的戒断反应 Luogu P10221. [省选联考 2024] 重塑时光 Luogu P5308 [COCI2018-2019#4] Akvizna wqs 二分 歌唱王国 Lean 相关 BZOJ 3153. Sone1 The 2023 ICPC World Finals Luxor 新巴别塔 Sora 的想象与思考 Facebook Hacker Cup 2023 Round 1 AtCoder Beginner Contest 322 LLaMA 2 相关 HuggingFace AI Game Jam ACL 2023 Trans 相关… Luogu P2053. [SCOI2007] 修车 Luogu P1973. [NOI2011] NOI 嘉年华 Luogu P1933. [NOI2010] 旅行路线 Luogu P1954. [NOI2010] 航空管制 Luogu P2048. [NOI2010] 超级钢琴 Luogu P2046. [NOI2010] 海拔
Luogu P2179. [NOI2012] 骑行川藏
2023-06-23 · via 某岛

June 23, 2023

最优解情况下每个分量的导数相同,二分这个导数即可。

#include <lastweapon/io>
using namespace lastweapon;

const int N = int(1e4) + 9;
int n;
double e, s[N], k[N], u[N];

double calcV(double x, int i) {
    double l = 0, r = INF, mid;
    int cnt = 233;
    while(cnt--) {
        mid = (l+r)/2;
        if(2*k[i]*s[i]*mid*mid*(mid-u[i])*x > -s[i]) l = mid ;else r = mid;
    }
    return (l+r)/2;
}

double calcE(double x) {
    double res = 0;
    REP(i, n) {
        double v = calcV(x, i);
        res += k[i]*(v-u[i])*(v-u[i])*s[i];
    }
    return res;
}

int main() {

#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif

    RD(n);
    RF(e);
    REP(i, n) RF(s[i], k[i], u[i]);
    double l = -INF, r = 0, mid;
    DO(100){
        mid = (l+r)/2;
        if(calcE(mid) <= e) l = mid ;else r = mid;
    }
    mid = (l+r)/2;
    double ans = 0;
    REP(i, n) ans += s[i] / calcV(mid, i);
    printf("%.6lf", ans);
}

Posted by xiaodao
Category: 日常