SCU2016-05 E题二分
来源:互联网 发布:淘宝网旗袍 编辑:程序博客网 时间:2024/06/05 09:59
Analyse:
就是二分+贪心判断,强行加eps不要。。
/**********************jibancanyang************************** *Author* :jibancanyang *Created Time* : 三 7/13 09:56:34 2016**Problem**:**Get**:**Code**:***********************1599664856@qq.com**********************/#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <cmath>#include <cstdlib>#include <ctime>#include <stack>using namespace std;typedef pair<int, int> pii;typedef long long ll;typedef unsigned long long ull;typedef vector<int> vi;#define pr(x) cout << #x << ": " << x << " " #define pl(x) cout << #x << ": " << x << endl;#define pri(a) printf("%d\n",(a))#define xx first#define yy second#define sa(n) scanf("%d", &(n))#define sal(n) scanf("%lld", &(n))#define sai(n) scanf("%I64d", &(n))#define vep(c) for(decltype((c).begin() ) it = (c).begin(); it != (c).end(); it++) const int mod = int(1e9) + 7, INF = 0x3f3f3f3f;const int maxn = 1e4 + 13;int n, f;int pie[maxn];double pi = acos(-1), eps = 1e-7;bool judge(double mid) { int sum = 0; for (int i = 0; i < n; i++) { int te = double(pie[i]) * pie[i] * pi / mid; sum += te; } return sum >= f;}int main(void){#ifdef LOCAL freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);#endif int T; sa(T); while (T--) { sa(n), sa(f); f++; for (int i = 0; i < n; i++) sa(pie[i]); double l = 0, r = 1e10; for (int i = 0; i < 250; i++) { double mid = (l + r) / 2; if (judge(mid)) { l = mid + eps; } else r = mid - eps; } printf("%.4f\n", l); } return 0;}
0 0
- SCU2016-05 E题二分
- SCU2016-05 F题二分最大化平均值
- SCU2016-05 G题双重二分
- SCU2016-01 E题 贪心
- SCU2016-02 S题 区间二分
- SCU2016-05 R题数学模拟
- SCU2016-05 J题构造
- SCU2016-03 P题 二分+DLX可重复覆盖
- SCU2016-03 O题二分 + DLX可重复覆盖
- SCU2016-01 H题 (二分图带权匹配 KM算法)
- SCU2016-01 I题 二分 + 斜率优化dp
- SCU2016-02 E 动态贪心
- SCU2016-05 A题无向图割顶
- SCU2016-05 P题数学构造
- SCU2016-05 K题 (模拟水)
- 二分贪心 E题
- SCU2016-01 M题
- SCU2016-04 A题
- mysql 查询大数据导出都是怎么做的?
- iOS 在App内返回到指定页面
- 当你使用maven,怎样install也失败时
- Leetcode 7. Reverse Integer (Easy) (cpp)
- 230. Kth Smallest Element in a BST
- SCU2016-05 E题二分
- Android中关于Fragment的使用和Fragment的生命周期
- Dialog样式的Activity
- tomcat启动时一闪而过的几种原因
- Toolbar使用详解
- Hibernate 多表关联查询示例
- BZOJ3939 [Usaco2015 Feb]Cow Hopscotch
- android开源图表库MPAndroidChart
- 在C#中使用SerialPort类实现串口通信