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)。满足条件的x≥(a-b)/(2*n)
假设在下降的那段,2*x-(a-2*x*n)=b,n+1≤(a+b)/(2*b),x≥(a+b)/(2*(n+1))
两者取最小值
#include<bits/stdc++.h>
using namespace std; int main()
{
int a,b; scanf("%d%d",&a,&b);
if(a<b) puts("-1");
else {
int t1 = a+b, t2 = a-b;
int n1 = t1/(*b)*, n2 = t2/(*b)*;
double a1 = t1*./n1, a2 = t2*./n2;
printf("%.10lf\n",min(a1,a2));
}
return ;
}
Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] A A Problem about Polyline(数学)的更多相关文章
- 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 ...
- 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 ...
- Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] B. "Or" Game
题目链接:http://codeforces.com/contest/578/problem/B 题目大意:现在有n个数,你可以对其进行k此操作,每次操作可以选择其中的任意一个数对其进行乘以x的操作. ...
- Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] E. Weakness and Poorness 三分
E. Weakness and Poorness time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] A. Raising Bacteria【位运算/二进制拆分/细胞繁殖,每天倍增】
A. Raising Bacteria time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] D 数学+(前缀 后缀 预处理)
D. "Or" Game time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] E 三分+连续子序列的和的绝对值的最大值
E. Weakness and Poorness time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] C A Weakness and Poorness (三分)
显然f(x)是个凹函数,三分即可,计算方案的时候dp一下.eps取大了会挂精度,指定循环次数才是正解. #include<bits/stdc++.h> using namespace st ...
- Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] B "Or" Game (贪心)
首先应该保证二进制最高位尽量高,而位数最高的数乘x以后位数任然是最高的,所以一定一个数是连续k次乘x. 当出现多个最高位的相同的数就枚举一下,先预处理一下前缀后缀即可. #include<bit ...
随机推荐
- FZU2216【二分】
题意: 百度. 思路: 一个连续数组111222233344444555666的每一个起伏转折即需要一张万能牌. 然后二分一下得最长区间. #include<cstdio> #includ ...
- PowerDesigner设计表时显示注释列Comment,Columns中没有Comment的解决办法
我使用的PowerDesigner版本为16.5,如下图: 在所要编辑的表上双击,打开Table Properties窗口,并将上面的选项卡切换到Columns,如下图: 我们点击Customize ...
- 同余方程 (codevs1200)
题目描述××× 求关于 x 的同余方程 ax ≡ 1 (mod b)的最小正整数解. 输入输出格式××× 输入格式: 输入只有一行,包含两个正整数 a, b,用一个空格隔开. 输出格式: 输出只有一行 ...
- pytest框架(四)
测试用例setup和teardown 代码示例一 # coding=utf-8 import pytest def setup_module(): print("setup_module:整 ...
- selenium IDE插件下载
1.在https://addons.mozilla.org/en-US/firefox/addon/selenium-ide/中下载Firefox的selenium-ide插件: 2.之后在Firef ...
- Centos7中给gitLab汉化
第一步:安装git 下载补西,东西在清华大学开源中心 yum install –y git 第二步:下载 git clone https://gitlab.com/xhang/gitlab.git 第 ...
- java获取本机ip的方法
直接上代码: public class LocalIPUtil { public static String getLocalIp(HttpServletRequest request){ Strin ...
- MySQL创建用户+授权+备份
======权限管理====== 我们知道我们的最高权限管理者是root用户,它拥有着最高的权限操作.包括select.update.delete.update.grant等操作. 那么一般情况在公司 ...
- Python3.x下Selenium3.x之安装篇
环境安装 Python环境: 首先我们需要安装Python语言,这个不过多详述,仅给出建议 Python2.x目前支持的第三方库类较多 Python3.x是修改了许多2.x版本的不足,但支持的库类较少 ...
- JS 对象的操作方法
第一种: 变量名.style.属性: 第二种: 变量名.style[参数]