## veget_chicken的博客

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 value x such that it is true or determine that there is no such 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;
}

#### hdu 2050 折线分割平面（图形递推题）

2016-05-09 18:19:14

#### Sgu 128 Snake

2013-09-08 10:06:57

#### #1696: 折线中点

2018-03-02 23:12:08

#### hdu 2050折线分割平面（递推找规律）

2017-04-18 17:02:05

#### bzoj1573 [Usaco2009 Open]牛绣花cowemb

2016-05-18 09:04:09

#### HDU 1040 As Easy As A+B 排序

2009-11-26 01:33:00

#### Codeforces 149D Coloring Brackets 【区间dp】

2016-01-10 16:59:23

#### 贪心算法：田忌赛马－HDU1052 & POJ2287 & ZOJ2397

2014-02-13 22:37:42

#### hdu An easy problem （背包）

2015-07-24 19:39:11