题目描述

邱老师是妖怪爱好者,他有n只妖怪,每只妖怪有攻击力atk和防御力dnf两种属性。邱老师立志成为妖怪大师,于是他从真新镇出发,踏上未知的旅途,见识不同的风景。

环境对妖怪的战斗力有很大影响,在某种环境中,妖怪可以降低自己k*a点攻击力,提升k*b点防御力或者,提升自己k*a点攻击力,降低k*b点防御力,a,b属于正实数,k为任意实数,但是atk和dnf必须始终非负。

妖怪在环境(a,b)中的战斗力为妖怪在该种环境中能达到的最大攻击力和最大防御力之和。strength(a,b)=max(atk(a,b))+max(dnf(a,b))环境由a,b两个参数定义,a,b的含义见前文描述。

比如当前环境a=3,b=2,那么攻击力为6,防御力为2的妖怪,能达到的最大攻击力为9,最大防御力为6。所以该妖怪在a=3,b=2的环境下战斗力为15。

因此,在不同的环境,战斗力最强的妖怪可能发生变化。

作为一名优秀的妖怪训练师,邱老师想发掘每一只妖怪的最大潜力,他想知道在最为不利的情况下,他的n只妖怪能够达到的最强战斗力值,即存在一组正实数(a,b)使得n只妖怪在该环境下最强战斗力最低。

输入输出格式

输入格式:

第一行一个n,表示有n只妖怪。接下来n行,每行两个整数atk和dnf,表示妖怪的攻击力和防御力。1<=n<=10^6, 0<atk,dnf<=10^8

输出格式:

输出在最不利情况下最强妖怪的战斗力值,保留4位小数。

题意:
n只妖怪,有atk和dnf属性,每次可以选择一个环境a,b:可以使atk下降a*k,dnf上升b*k,或者相反,定义潜力为环境中最大atk和dnf的和,选择环境最小化最大的潜力;

题解:
①首先和a,b具体的值是无关的,只与a,b的比值有关:简化关系对于却定的a/b最大的潜力值是mx = A+B+A*b/a + B*a/b (令atk=A,dnf=B),      
令 k = -b/a,mx = A+B-(A*(1/k) + B*(k));后半部分对勾函数在k=sqrt(A/B)取得最小值;

②联想对于一个定点(x,y)斜率为k,那么其在x,y轴上的截距为:

x + y – x*k – y*(1/k),所以令x为B,y为A,就变成了截距的最大值最小。那么确定的k对n个点截距最大的一定在上凸包的右半部分上。

②枚举凸包上的点,如果k=sqrt(A/B)可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fDtbm12ce907/3rmfwsAZhLUQOvEedNx/nSvsveT7h2dPvcP/mkY+dxnsjUA6E9QA60UozrOrc7DenTGHUGK9M6fXv3k97IlACjmLh+U5qp22qj3bh4zubsHRRwPgV5GqIFO8xAYAKoS1ECnFV10WHaKCACY8kFpfsQJkHI8BHoZoQYAgAoENQAAVCCoAQCgAkENAAAVCGoAAKhAUAMAQAWCGgAAKhDUAABQgaAGAIAKBDUAAFQgqAEAoAJBDQAAFQhqAACoQFADAEAFghoAACoQ1AAAUIGgBgCACgQ1AABUIKgBAKACQQ0AABUIagAAqEBQAwBABYIaAAAqENQAAFCBoAYAgAoENQAAVCCoAQCgAkENAAAVCGoAAKhAUAMAQAWCGgAAKhDUAABQgaAGAIAKBDUAAFQgqAEAoAJBDQAAFQhqAACoQFADAEAFghoAACoQ1AAAUIGgBoB5+uCDD06/AAQ1AABUIKgBAKACQQ0AABUIagAAqGDZB66oAACABTNCDQAAFQhqAACoQFADAEAFghoAACoQ1AAAUIGgBgCACgQ1AABUIKgBAKACQQ0AABUIagAAqEBQAwBABYIaAAAqENQAAFCBoAYAgAoENQAAVCCoAQCgAkENAAAVCGoAAKhAUAMAQAWCGgAAKhDUAABQgaAGAIAKBDUAACxYCP8fVyeSPhjCk1IAAAAASUVORK5CYII=" alt="" />

算很隐蔽了吧。

 #include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
const int N = ;
double inf = 1e15;
int n,m;
struct point{
int x,y;
point(int x = ,int y = ):x(x),y(y){}
bool operator < (const point &a)const{return (x==a.x)?y<a.y:x<a.x;}
point operator - (const point &a){return point(x-a.x,y-a.y);}
}p[N],ch[N];
char gc(){
static char *p1,*p2,s[];
if(p1==p2) p2=(p1=s)+fread(s,,,stdin);
return(p1==p2)?EOF:*p1++;
}
int rd(){
int x = ,f = ; char c = gc();
while(c<''||c>'') {if(f=='-') f = -; c = gc();}
while(c>=''&&c<='') x = x * + c -'',c = gc();
return x * f;
}
const double eps = 1e-;
int dcmp(double x){return (fabs(x)<eps)?:x<?-:;}
ll cross(point a,point b){return 1ll*a.x*b.y - 1ll*b.x*a.y;}
void convexhull(){
sort(p+,p+n+);
for(int i = n;i>=;i--){
while(m>&&dcmp(cross(ch[m]-ch[m-],p[i]-ch[m])<=)) m--;
ch[++m] = p[i];
}
}
double K(point a,point b){return 1.0*(a.y-b.y)/(a.x-b.x);}
double calc(double k,point a){return a.x+a.y-/k*a.y-k*a.x;}
int main()
{ //freopen("bzoj4570.in","r",stdin);
//freopen("bzoj4570.out","w",stdout);
n = rd();
for(int i = ,A,B;i <= n;i++) {
A = rd(); B = rd();
p[i] = point(B,A);
}
convexhull();
double ans = inf;
for(int i = ;i <= m;i++){
double k1 = (i!=m)?K(ch[i],ch[i+]):;
double k2 = (i!=)?K(ch[i],ch[i-]):-inf;
double k = -sqrt(1.0 * ch[i].y / ch[i].x);
if(dcmp(k1-k)>=&&dcmp(k-k2)>=)
ans = min(ans,calc(k,ch[i]));
if(i!=m&&ch[i+].y<ch[i].y) break;
if(i!=m) ans = min(ans,calc(k1,ch[i]));
}
printf("%.4lf\n",ans);
return ;
}//by tkys_Austin;

【bzoj4570 scoi2016】妖怪的更多相关文章

  1. BZOJ4570: [Scoi2016]妖怪

    题目传送门 4570: [Scoi2016]妖怪 Time Limit: 10 Sec Memory Limit: 64 MB Submit: 491 Solved: 125 [Submit][Sta ...

  2. [Bzoj4570][Scoi2016]妖怪(右上凸包)

    4570: [Scoi2016]妖怪 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 1110  Solved: 336[Submit][Status][ ...

  3. [BZOJ4570][SCOI2016]妖怪(凸包)

    两种做法,前一种会TLE. 第一种是高一数学题做法,设一个妖怪的atk和dnf分别为x和y,则它在(a,b)环境下的战斗力为x+y/a*b+y+x/a*b. 设t为b/a,则战斗力即$f(x,y,t) ...

  4. BZOJ4570 SCOI2016妖怪(三分)

    strength=atk*(1+b/a)+dnf*(1+a/b).设a/b=x,可以发现这是一个关于x的对勾函数.开口向上的一堆凸函数取max还是凸函数,三分即可. 然而无良出题人既卡精度又卡时间.众 ...

  5. 2018.10.15 bzoj4570: [Scoi2016]妖怪(凸包)

    传送门 不得不说这题有点东西啊. 看到题第一眼二分,用二次函数求范围来进行checkcheckcheck,20分滚粗了233. 于是开始思考正解. 发现可以把每只怪物的二元组属性看成二维坐标. 这时对 ...

  6. BZOJ 4570: [Scoi2016]妖怪

    二次联通门 : BZOJ 4570: [Scoi2016]妖怪 二次联通门 : luogu P3291 [SCOI2016]妖怪 LibreOJ : LibreOJ  #2015. 「SCOI2016 ...

  7. BZOJ4570:[SCOI2016]妖怪——题解

    https://www.lydsy.com/JudgeOnline/problem.php?id=4570 邱老师是妖怪爱好者,他有n只妖怪,每只妖怪有攻击力atk和防御力dnf两种属性.邱老师立志成 ...

  8. 【BZOJ4570】 [Scoi2016]妖怪

    Description 邱老师是妖怪爱好者,他有n只妖怪,每只妖怪有攻击力atk和防御力dnf两种属性.邱老师立志成为妖怪大师,于 是他从真新镇出发,踏上未知的旅途,见识不同的风景.环境对妖怪的战斗力 ...

  9. P3291 [SCOI2016]妖怪

    传送门 我数学的确白学了--这种题目竟然一点思路都没有-- 首先可以把每个妖怪看成二维平面上的一个点,那么每一个环境\((a,b)\)就可以看成一条斜率\(k=-\frac{b}{a}\)的过该点的直 ...

随机推荐

  1. 算法——算法时间复杂度的计算和大O阶的推导

    在算法分析中,我们将语句总的执行次数记为T(n)进而分析T(n)随n的变化情况确认T(n)的数量级.一般情况下,T(n)随n增大变化最缓慢的算法为最优算法. 根据定义,T(n)的求法是很简单的,也就是 ...

  2. 个人作业2——NBA 2k18案例分析

    产品:篮球体育类游戏NBA 2k18 选择理由:这款游戏是<NBA 2k>的正统续作,自己和身边的朋友都对篮球比较感兴趣,经常看NBA,所以近几年的版本都有购买下载,加上游戏中人物动作比较 ...

  3. 第二次作业:APP案例分析

    App案例分析 产品:三国杀-页游手游双通 选择理由 当今社会手机已经渐渐取代了电脑在人们日常生活的需求,既然要选择APP进行案例分析,首推的估计就是手机APP了.三国杀是陪伴我高中时代的主要娱乐方式 ...

  4. 201621123057 《Java程序设计》第6周学习总结

    1. 本周学习总结 1.1 面向对象学习暂告一段落,请使用思维导图,以封装.继承.多态为核心概念画一张思维导图或相关笔记,对面向对象思想进行一个总结. 注1:关键词与内容不求多,但概念之间的联系要清晰 ...

  5. nyoj 孪生素数

    孪生素数问题 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 写一个程序,找出给出素数范围内的所有孪生素数的组数.一般来说,孪生素数就是指两个素数距离为2,近的不能再 ...

  6. js定时刷新页面.

    //页面定时刷新.2017.09.27 $(document).ready(function () { self.setInterval(function () { var d = new Date( ...

  7. vue项目中的常见问题

    总结了几个vue项目开发过程中遇到的常见问题,希望大家注意. 注:文末有福利! 一.样式问题 1.vue中使用less 安装less依赖 npm install less less-loader -- ...

  8. GIT入门笔记(19)GIT 小结

    1.add和commit为什么Git添加文件需要add,commit一共两步呢?因为commit可以一次提交很多文件,所以你可以多次add不同的文件,比如:$ git add file1.txt$ g ...

  9. 我的jquery validate 笔记

    <!DOCTYPE html><html lang="en">    <head>    <meta charset="UTF- ...

  10. jprofiler配置

    cataline.sh JAVA_OPTS="$JAVA_OPTS -agentlib:jprofilerti=port=8849"JAVA_OPTS="$JAVA_OP ...