题意:一个等腰直角三角形一样的周期函数(只有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. JUnit Parametrized Tests

    Junit allows us to create parametrized tests. Parametrized test class has to be annotated with the @ ...

  2. C# 监控代码执行效率

    System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); stop ...

  3. ODAC(V9.5.15) 学习笔记(七)TOraUpdateSQL

    名称 类型 说明 DataSet 指向需要执行更新操作的数据集 DeleteObject 当执行删除操作时,通过该属性执行另外一个数据集,由后者来执行更多的删除动作 DeleteSQL TString ...

  4. 怎么删除git本地分支以及Bitbucket的远程分支?

    1. 如果分支只是本地分支,则可以使用 -d (如果分支已合并),例如 git branch -d <branch name>如果分支包含不计划合并的代码,请改用 -D (即使有没有mer ...

  5. matlab练习程序(k-means聚类)

    聚类算法,不是分类算法. 分类算法是给一个数据,然后判断这个数据属于已分好的类中的具体哪一类. 聚类算法是给一大堆原始数据,然后通过算法将其中具有相似特征的数据聚为一类. 这里的k-means聚类,是 ...

  6. resure挽救笔记本系统和一些相关的操作记录

    使用fedora23很久了, 但是感觉不是很流畅, 出现了一些不太稳定的体验, 所以想改到centos7. 因为centos7的很多东西 跟 fedora23 很相近了. 所以应该是无缝过渡 是选择3 ...

  7. Depth-first search and Breadth-first search 深度优先搜索和广度优先搜索

    Depth-first search Depth-first search (DFS) is an algorithm for traversing or searching tree or grap ...

  8. 解决 dpkg: warning: files list file for package 'x' missing 问题

    参考: dpkg: warning: files list file for package 'x' missing 解决 dpkg: warning: files list file for pac ...

  9. Git 常用使用技巧

    1.创建代码仓库 Step 1:先配置下我们的身份吧,这样在提交代码的时候Git就可以知道是谁提交的,命令如下: git config --global user.name "coder-p ...

  10. Redux 管理React Native数据

    现在让我们看看大致的流程: React 可以触发 Action,比如按钮点击按钮. Action 是对象,包含一个类型以及相关的数据,通过 Store 的 dispatch() 函数发送到 Store ...