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 ...
随机推荐
- python3.5 jira网站实现用户的批量插入
工作中,经常要给多个用户创建账号,为了减少工作量,写了个自动化脚本来帮助我批量创建用户 代码如下: """自动创建Jira的学生账号""" ...
- python中出现 IndentationError:unindent does not match any outer indentation level
python中出现IndentationError:unindent does not match any outer indentation level 今天在网上copy的一段代码,代码很简单,每 ...
- HDU - 2962 Trucking SPFA+二分
Trucking A certain local trucking company would like to transport some goods on a cargo truck from o ...
- 2014-11-1 NOIP模拟赛2
一.题目概览 中文题目名称 连连看 取数 游戏 迎接仪式 英文题目名称 card cycle game welcome 可执行文件名 card cycle game welcome 输入文件名 car ...
- 2014-10-6 NOIP模拟赛
1. 锻炼计划(exercise.pas) 身体是革命的本钱,OIers不要因为紧张的学习和整天在电脑前而忽视了健康问题.小x设计了自己的锻炼计划,但他不知道这个计划是否可行,换句话说如果计划不当可能 ...
- uoj#308. 【UNR #2】UOJ拯救计划(并查集)
传送门 如果把答案写出来,就是\(\sum_{i=1}^ki!\times {k\choose i}\times f_i\),其中\(f_i\)为选\(i\)种颜色方案 发现如果\(i\geq 3\) ...
- iphone6 iphone6 plus 放大显示模式高分辨率模式问题
分为兼容模式和高分辨率模式. 兼容模式 当你的 app 没有提供 3x 的 LaunchImage 时,系统默认进入兼容模式,大屏幕一切按照 320 宽度渲染,屏幕宽度返回 320:然后等比例拉伸到大 ...
- java基础第八篇之jdk1.5、jdk1.7、jdk1.8新特性
JDK5新特性 自动装箱和拆箱 泛型 增强for循环 静态导入 可变参数 枚举 枚举概述 是指将变量的值一一列出来,变量的值只限于列举出来的值的范围内.举例:一周只有7天,一年只有12个月等. 回想单 ...
- Django + Vue cli 3.0 访问静态资源问题
[问题背景] 用Vue clie 3.0的搭建得框架把我坑死了,在打包后,调用不到静态资源js,css,mp3等 [问题原因] vue cli 3.0打包后,dist目录下没有static目录,而Dj ...
- CF1141F Same Sum Blocks(easy/hard)
传送门easy 传送门hard 切水题的感觉真好 看到数据范围这么小,所以暴力枚举所有的可能,然后用map+vector存下每种值的区间,然后贪心去选 代码: #include<cstdio&g ...