ACM-ICPC World Finals 2017
来源:互联网 发布:大数据 技术 图 编辑:程序博客网 时间:2024/04/26 11:56
Sheila is a student and she drives a typical student car: it is old, slow, rusty, and falling apart. Recently, the needle on the speedometer fell off. She glued it back on, but she might have placed it at the wrong angle. Thus, when the speedometer reads
Sheila made a careful record of a recent journey and wants to use this to compute
Note that while Sheila’s speedometer might have negative readings, her true speed was greater than zero for each segment of the journey.
Input
The first line of input contains two integers
Output
Display the constant
3 54 -14 010 3
3.000000000
4 105 32 23 63 1
题意:
二分查找结果。
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; int v[1100], d[1100], n; double t; int slove(double c){ double te = 0; for(int i =0; i<n; i++){ if ((c + v[i]) <= 0) return -1; else te += 1.0*d[i] /(c + v[i]); } if( te < t) // 返回1表示c取大了 return 1; else return -1; } int main(){ while(scanf("%d%lf", &n,&t) != EOF){ for(int i =0; i < n; i++){ scanf("%d%d", &d[i], &v[i]); } double le = -1e9, ri = 1e9, mid = (le + ri) / 2; int flag, cnt = 62; while((ri - le) > 1e-6){ flag = slove(mid); if(flag > 0){ ri = mid; mid = (le + ri) /2; } else { le = mid; mid = (le + ri) /2; } } printf("%0.6lf\n", mid); } return 0; }
- ACM-ICPC World Finals 2017
- ACM-ICPC 2013 World Finals 简单题解
- Puzzle, ACM/ICPC World Finals 1993, UVa227
- ACM/ICPC World Finals 2013 D Factors
- ACM/ICPC World Finals 2010 D Castles
- Puzzle,ACM/ICPC World Finals 1993,UVa227
- Gym 101205 (ACM-ICPC World Finals 2012)
- Puzzle,ACM/ICPC World Finals 1993, UVa227
- Sqaures, ACM/ICPC World Finals 1990, UVa
- 浙江大学获ACM-ICPC World Finals …
- 【ACM ICPC World Finals 2012】 Curvy Little Bottles (二分)
- Crossword Answers, ACM/ICPC World Finals 1994, UVa232
- Repeating Decimals, ACM/ICPC World Finals 1990, UVa202
- ACM/ICPC World Finals 2013 A Self-Assembly
- ACM/ICPC World Finals 2013 C Surely You Congest
- ACM/ICPC World Finals 2013 F Low Power
- ACM/ICPC World Finals 2012 D Fibonacci Words
- ACM/ICPC World Finals 2012 B Curvy Little Bottles
- http
- ubuntu16下python3 + flask环境搭建
- 对RESTFUL理解
- LeetCode题库——TwoSum
- 1.2换行输出
- ACM-ICPC World Finals 2017
- ionic滑动
- drop_caches Linux清空缓存
- 关于animation PlayState在ios上不起作用, 以及ios前端页面音乐不能自动播放的问题
- jquery 中如何将数组转化为json字符串,然后再转化回来?
- 送给理财新手的十五句话
- /*输出100以内所有还7或7的倍数*\此程序在if那里有点繁琐,请大神指点一下,谢谢
- 使用 Addr2line 将函数地址解析为函数名
- java中split()特殊符号"." "|" "*" "\" "]"