# 「一本通 1.1 例 3」喷水装置

## 解题思路

#include <bits/stdc++.h>
#define _for(i,a,n) for(int i=a;i<n;++i)
#define rep(i,a,n)for(int i=a;i<=n;++i)
#define input() int T;cin>>T;while(T--)
#define close() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
using namespace std;
const int maxn = 15000;
struct node {
double l, r;
inline bool operator < (const node &b) const {
return l < b.l;
}
}arr[maxn + 5];

int main()
{
int T;
double n, x, r, L, W;
while(T--) {
int tot = 0;
_for(i, 0 , n) {
if(r * 2 <= W) continue;
arr[++tot].l = x - sqrt(r * r - W * W / 4.0);
arr[tot].r = x + sqrt(r * r - W * W / 4.0);
}
sort(arr + 1, arr + tot + 1);
double st = 0;
int ans = 0;
while(st < L) {
ans++;
double tmp = st;
for(int id = 1; arr[id].l <= tmp && id <= tot; ++id)
st = max(st, arr[id].r);
if(st == tmp && st < L) {
ans = -1;
break;
}
}
cout << ans << endl;
}
return 0;
}
posted @ 2018-12-25 08:23  schrodingercatss  阅读(...)  评论(... 编辑 收藏