(二分,数学积分)icpc2015,D.Cutting Cheese
来源:互联网 发布:mysql全国地区数据库 编辑:程序博客网 时间:2024/05/28 23:20
Cutting Cheese
DIFFICULTY
1.5Swiss cheese such as Emmentaler has holes in it, and the holes may have different sizes. A slice with holes contains less cheese and has a lower weight than a slice without holes. So here is the challenge: cut a cheese with holes in it into slices of equal weight.
By smart sonar techniques (the same techniques used to scan unborn babies and oil fields), it is possible to locate the holes in the cheese up to micrometer precision. For the present problem you may assume that the holes are perfect spheres.
Each uncut block has size
Input
The first line of the input contains two integers
The cheese block occupies the points
You may assume that holes do not overlap but may touch, and that the holes are fully contained in the cheese but may touch its boundary.
Output
Display the
0 4
25.00000000025.00000000025.00000000025.000000000
2 510000 10000 20000 2000040000 40000 50000 60000
14.61110314216.26980173424.09245778827.00299227218.023645064
/*题目:Cutting Cheese链接:https://icpc.kattis.com/problems/cheese题意:有一个100*100*100的奶酪,里面有n个不相交的圆孔,问要切成k层,每一层需要分别为多厚?分析:二分,数学积分。1.用积分求不完整圆孔的体积。2.二分查找质量为相应质量的奶酪对应的高度,则易求得答案。*/#include <iostream>#include <cstdio>#include <cstring>#include <vector>#include <algorithm>using namespace std;const int maxn = 10005;const double pai = acos(-1);const double EPS = 1e-8;typedef long long LL;const int INF = 0xfffffff;int input(){int a;scanf("%d", &a);return a;}/*-------------------------------------------*/const double daf = 100;int N, S;struct NODE{double r, x, y, z;}a[maxn];vector<double> ans;/********************************************/double area(double r){return 4.0 / 3 * pai*r*r*r;}double cal(double R, double H){return 1.0 / 3 *pai* (2.0*R*R*R - 3.0*R*R*H + H*H*H);}double Judge(double hori){double sum = daf * daf * hori;for (int i = 0; i<N; i++)//对每一个圆{if (a[i].z - a[i].r >= hori)continue;//完全在hori之上else if (a[i].z + a[i].r <= hori)//完全在hori之下{sum -= area(a[i].r);}else if (a[i].z>=hori&&hori >= a[i].z - a[i].r)//下半部分在hori之下{sum -= cal(a[i].r,a[i].z - hori);}else if (a[i].z+a[i].r>=hori&&hori >= a[i].z)//上半部分在hori之上{sum -= (area(a[i].r) - cal(a[i].r, hori-a[i].z));}}return sum;}void solve(double des){double l = 0, u = daf;while (fabs(u - l) > EPS){double mid = (l + u) / 2;if (Judge(mid) > des)u = mid;elsel = mid;}ans.push_back((l + u) / 2);}/********************************************/int main(){//#ifdef LOCAL_JUDGE//freopen("f:\\input.txt", "r", stdin);//#endifwhile (~scanf("%d%d", &N, &S)){double sum = daf * daf * daf;for (int i = 0; i < N; i++){scanf("%lf%lf%lf%lf", &a[i].r, &a[i].x, &a[i].y, &a[i].z);a[i].r /= 1000;a[i].x /= 1000;a[i].y /= 1000;a[i].z /= 1000;sum -= area(a[i].r);}double per = sum / S;ans.clear();ans.push_back(0);for (int i = 1; i <= S-1; i++){solve(per*i);}ans.push_back(100);for (int i = 1; i < ans.size(); i++){printf("%.9f\n", ans[i] - ans[i - 1]);}}return 0;}
- (二分,数学积分)icpc2015,D.Cutting Cheese
- icpc2015 D Cutting Cheese(二分+球缺体积)
- 2015final题 Cutting Cheese 二分切点+积分
- HDU 2493 Timer 数学(二分+积分)
- Codeforces Round #341 (Div. 2) D. Rat Kwesh and Cheese(数学 | 复数)
- Codeforces Round #341 (Div. 2) Editorial D - Rat Kwesh and Cheese(数学,高精度)
- Codeforces-448【A数学函数ceil】【B思维】【D二分】
- Codeforces 448D: Multiplication Table(二分+数学)
- [Codeforces#475D]CGCDSSQ(st表+二分+数学相关)
- hdu5761Rower Bo+数学积分
- HDU 5826 数学积分
- hdu5826physics+数学积分
- hdu1071The area+数学积分
- Codeforces 621 D Rat Kwesh and Cheese
- Cheese
- cheese
- D二分
- HDU 4808 数学 期望 积分
- 三层实战(C#)
- Qt 模仿苹果状态切换按钮
- TestNG 入门教程
- Android Fragment 真正的完全解析(上)
- Android 图片加载优化
- (二分,数学积分)icpc2015,D.Cutting Cheese
- junit
- iproute2_examples
- 儿童节献给孩子的书单
- Python Show-Me-the-Code 第 0020题 统计通话时长
- iOS开发 -"ASI"使用实例
- IOS -- 获取WIFI信息API
- 32.图形上下文
- xbmc从onKey到onAction创建CAction对象的过程