A Problem about Polyline
来源:互联网 发布:万网网络空间购买 编辑:程序博客网 时间:2024/04/26 19:43
链接:
题目:
题意:一条以x为比例因子渐增的折线,给一个点判断该点能否出现在该折线上,以及如果能,求最小的x
分析:数学题,主要是判断之后,找到点左右的两个折线与x轴相交的点(其实是两种情况,在折线的上升沿和下降沿),然后分别作为最小情况求出x的值,比较后留下最小的。
题解:
题目:
There is a polyline going through points (0, 0) – (x, x) – (2x, 0) – (3x, x) – (4x, 0) – ... - (2kx, 0) – (2kx + x, x) – ....
We know that the polyline passes through the point (a, b). Find minimum positive valuex such that it is true or determine that there is no suchx.
题意:一条以x为比例因子渐增的折线,给一个点判断该点能否出现在该折线上,以及如果能,求最小的x
分析:数学题,主要是判断之后,找到点左右的两个折线与x轴相交的点(其实是两种情况,在折线的上升沿和下降沿),然后分别作为最小情况求出x的值,比较后留下最小的。
题解:
#include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <queue>#include <stack>#include <vector>#include <map>#include <string>#include <cstring>#include <functional>#include <cmath>#include <cctype>#include <cfloat>#include <climits>#include <complex>#include <deque>#include <list>#include <set>#include <utility>#define rt return 0#define fr freopen("in.txt","r",stdin)#define fw freopen("out.txt","w",stdin)using namespace std;double wr(int a, int b){int m = a / (2 * b);return (double)a / (double)(2 * m);}int main(){//fr;int a, b;cin >> a >> b;if (a<b){cout << -1 << endl;rt;}int t = a - b;int p = a + b;double ans = min(wr(p, b), wr(t, b));printf("%.10lf\n", ans);rt;}
0 0
- A Problem about Polyline
- cf 320# A Problem about Polyline (二分)
- cf#320 Div.2 Problem C A Problem about Polyline
- cf#320 Div.2 Problem C A Problem about Polyline
- Codeforces Round #320 (Div. 1) A. A Problem about Polyline
- Codeforces Round #320 (Div. 2)C. A Problem about Polyline
- Codeforces Round #320 (Div. 2) C. A Problem about Polyline
- [CodeForces 579C]A Problem about Polyline[数学]
- Codeforces Round #320 (Div. 2) C - A Problem about Polyline
- Codeforces Round #320 (Div. 2) C - A Problem about Polyline
- cf C. A Problem about Polyline (数学题)
- CodeForces 579C A Problem about Polyline[数学]
- codeforces 320c A Problem about Polyline(数学)
- Codeforces Round #320 (Div. 2) C. A Problem about Polyline
- 【26.09%】【codeforces 579C】A Problem about Polyline
- Codeforces Round #320 (Div. 2) 578A. A Problem about Polyline
- Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] C. A Problem about Polyline 精度控制
- Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] C. A Problem about Polyline
- [笔试] 分田地
- 简单的block传值
- 【笔试】两种排序方法
- [概率 高斯消元 逆矩阵] BZOJ 3640 JC的小苹果
- Spring 注解事件Event
- A Problem about Polyline
- android ScrollView判断滑动到底部的两种形式
- 数组值定下标
- pyqt 图片 用label的属性显示
- 【笔试】统计回文
- [数论] BZOJ 1406 [AHOI2007]密码箱
- Linux命令行与Shell脚本编程[学习笔记序]
- 【笔试】洗牌
- Maven 错误找不到符号