题意:一个等腰直角三角形一样的周期函数(只有x+轴),经过给定的点(a,b),并且半周期为X,使X尽量大,问X最大为多少?

如果a=b,结果就为b

如果a<b无解。

否则,b/(2*k*x-a)=1或者b/(a-2*k*x)=1;以前者为例,x=(a-b)/(2*k)。x越小越好,那么k尽量大,但是K过大,x就会小于b,x小于b就无法穿过(a,b)。k要大又不能过大就满足二分的要求,就能二分。

乱码:

//#pragma comment(linker,"/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include <stack>
#include <iomanip>
using namespace std;
const int SZ=,INF=0x7FFFFFFF;
const double EPS=1e-; double getr(double res,int b)
{
if(res<b)return 1e300;
int lo=,hi=1e9+;
for(;lo<hi;)
{
int mid=(lo+hi)/;
if(res/mid>=b||fabs(res/mid-b)<EPS*EPS)lo=mid+;
else hi=mid;
}
//cout<<res<<" "<<lo<<endl;
return res/(lo-);
} double work(double a,double b)
{
if(fabs(a-b)<EPS)return b;
else
{
double na=a,nb=b;
double res1=(na-nb)/,res2=(na+nb)/;
//
res1=getr(res1,b);
res2=getr(res2,b);
//cout<<res1<<" "<<res2<<endl;
return min(res1,res2);
}
} int main()
{
//std::ios::sync_with_stdio(0);
//freopen("d:\\1.txt","r",stdin);
//for(;scanf("%d",&n)!=EOF;)
{
double a,b;
cin>>a>>b;
if(a<b)cout<<-<<endl;
else
{
cout<<fixed<<setprecision()<<work(a,b)<<endl;
}
}
return ;
}

codeforces 578a//A Problem about Polyline// Codeforces Round #320 (Div. 1)的更多相关文章

  1. Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] C C Problem about Polyline 数学

                                                                           C. A Problem about Polyline   ...

  2. [Codeforces] Round #320 (Div.2)

    1.前言 虽然这次我依旧没有参加正式比赛,但是事后还是看了看题目的...一般不怎么刷Codeforces. A.Raising Bacteria You are a lover of bacteria ...

  3. 【解题报告】CF Round #320 (Div. 2)

    Raising Bacteria 题意:盒子里面的细菌每天会数量翻倍,你可以在任意一天放任意多的细菌,最后要使得某天盒子里面的细菌数量等于x,求至少要放多少个细菌 思路:显然,翻倍即为二进制左移一位, ...

  4. codeforces Round #320 (Div. 2) C. A Problem about Polyline(数学) D. "Or" Game(暴力,数学)

    解题思路:就是求数 n 对应的二进制数中有多少个 1 #include <iostream> #include<cstdio> using namespace std; int ...

  5. Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] A A Problem about Polyline(数学)

    题目中给出的函数具有周期性,总可以移动到第一个周期内,当然,a<b则无解. 假设移动后在上升的那段,则有a-2*x*n=b,注意限制条件x≥b,n是整数,则n≤(a-b)/(2*b).满足条件的 ...

  6. Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] C. Weakness and Poorness 三分 dp

    C. Weakness and Poorness Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  7. Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] B. "Or" Game 线段树贪心

    B. "Or" Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/578 ...

  8. Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] B. "Or" Game

    题目链接:http://codeforces.com/contest/578/problem/B 题目大意:现在有n个数,你可以对其进行k此操作,每次操作可以选择其中的任意一个数对其进行乘以x的操作. ...

  9. CF 578A A Problem about Polyline

    题意: There is a polyline going through points (0, 0) – (x, x) – (2x, 0) – (3x, x) – (4x, 0) – ... - ( ...

随机推荐

  1. python ---24 正则表达式 re模块

    一.正则表达式 1.字符组 ① [abc] 匹配a或b或c ②  [a-z] 匹配a到z之间的所有字⺟ [0-9]匹配所有阿拉伯数字 2.元字符 3.量词 4.重要搭配 ①  .*? ②  .*?x  ...

  2. topcoder srm 350 div1

    problem1 link 满足$a^{b}\leq5000000,b>1$的数字不多,有2000多个,直接暴力计算能组成哪些数字即可. import java.util.*; import j ...

  3. AndroidO Treble架构分析【转】

    本文转载自:https://blog.csdn.net/yangwen123/article/details/79835965 从AndroidO开始,google引入了Treble架构,目的是为了方 ...

  4. SpringCloud与Consul集成实现负载均衡

    一.背景 SpringCloud微服务目前比较流行,其中大都在使用的服务注册与发现是Eureka,最近研究了Consul的集群搭建,现使用Consul实现服务的负载均衡.其主要拓扑结构如下: 二.Co ...

  5. js希尔排序

    function shellSort (arr) { var len = arr.length; var increment = Math.floor(len/2); while(increment! ...

  6. [echarts] - echarts量化比较图表类型解析

    https://echarts.baidu.com/examples/editor.html?c=watermark <!DOCTYPE html> <!--用作两种货品的参数对比- ...

  7. ComponentOne 2017 V1 发布

    在刚刚庆祝完Visual Studio20周年之后,我们迎来了ComponentOne 2017年第一个重要的版本. ComponentOne Studio与Visual Studio 2017配合发 ...

  8. module.exports 与 exports

    module.exports 与 exports 注意:1 对于要导出的属性,可以简单直接挂到 exports 对象上2 对于类,为了直接使导出的内容作为类的构造器可以让调用者使用 new 操作符创建 ...

  9. Spring-test单元测试

    <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test& ...

  10. P1005 矩阵取数游戏

    传送门 思路: △ 区间动规 对于每行,有 f [ i ][ j ] 代表取区间 [ i , j ] 的最大值. 然后转移方程我们考虑,对于每一个新的 f [ i ][ j ],有两种情况(下面定义  ...