Description

给定一个100*100*100(单位:毫米)的奶酪方块,这个奶酪含有n个球形小孔。现在要求将这个奶酪切成s片使得每片质量相等。

Input

第一行包含两个整数n,s,表示奶酪有n个小空,要切成s片(0≤n≤10000,1≤s≤100)

接下来n行每行包含四个正整数r,x,y,z来描述每个小孔,r代表半径,(x,y,z)代表球心坐标。0≤r,x,y,z≤100,000(单位:微米)
我们假定切割必须垂直于z轴。对于小孔,孔与孔之间不会重叠(但可能相切),且每个孔都完全被奶酪包含(可能与奶酪边界相切)。

Output

从边界z=0依次输出每片的厚度(单位:毫米),输出答案与标准答案的相对误差或绝对误差不超过1e-6。

二分答案,由于球互不相交所以体积很好算,不完整的球体积用定积分可以推出公式,完整的用球的体积公式

#include<cstdio>
#include<cmath>
typedef long double ld;
const ld pi=acos(-.);
int n,s;
ld zs[],rs[],ps[];
ld V=;
ld get(ld x){
ld a=x*;
for(int i=;i<n;i++)if(zs[i]+rs[i]<=x){
a-=rs[i]*rs[i]*rs[i]*(./.*pi);
}else if(zs[i]-rs[i]<x){
ld z=x-zs[i];
a-=./.*pi*rs[i]*rs[i]*rs[i]+pi*(rs[i]*rs[i]*z-z*z*z/.);
}
return a;
}
ld cal(ld V){
ld L=,R=,M;
while(L+1e-<R){
M=(L+R)*.;
if(get(M)<V)L=M;
else R=M;
}
return L;
}
ld cals(ld x){
ld a=;
for(int i=;i<n;i++)if(zs[i]+rs[i]>=x&&zs[i]-rs[i]<=x){
ld z=x-zs[i];
a-=pi*(rs[i]*rs[i]-z*z);
}
return a;
}
int main(){
scanf("%d%d",&n,&s);
for(int i=,x;i<n;i++){
scanf("%d",&x);
rs[i]=x*0.001;
scanf("%d",&x);
scanf("%d",&x);
scanf("%d",&x);
zs[i]=x*0.001;
V-=rs[i]*rs[i]*rs[i]*(./.*pi);
}
ps[]=;
for(int i=;i<=s;i++)ps[i]=cal(i*V/s);
for(int i=;i<=s;i++)printf("%.9Lf\n",ps[i]-ps[i-]);
return ;
}

bzoj4109: [Wf2015]Cutting Cheese的更多相关文章

  1. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  2. BZOJ4115 : [Wf2015]Tile Cutting

    设一种方案里三角形上三个点的坐标分别为$(0,0),(-a,b),(c,d)$,则得到的平行四边形的面积为$ac+bd$. 设$d(n)$为$n$的约数个数,$D$为$d$的生成函数,则答案的生成函数 ...

  3. CF 371B Fox Dividing Cheese[数论]

    B. Fox Dividing Cheese time limit per test 1 second memory limit per test 256 megabytes input standa ...

  4. hdu 1078 FatMouse and Cheese

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...

  5. [ACM_几何] Metal Cutting(POJ1514)半平面割与全排暴力切割方案

    Description In order to build a ship to travel to Eindhoven, The Netherlands, various sheet metal pa ...

  6. 贪心 Codeforces Round #300 A Cutting Banner

    题目传送门 /* 贪心水题:首先,最少的个数为n最大的一位数字mx,因为需要用1累加得到mx, 接下来mx次循环,若是0,输出0:若是1,输出1,s[j]--: 注意:之前的0的要忽略 */ #inc ...

  7. 水题 Codeforces Round #300 A Cutting Banner

    题目传送门 /* 水题:一开始看错题意,以为是任意切割,DFS来做:结果只是在中间切出一段来 判断是否余下的是 "CODEFORCES" :) */ #include <cs ...

  8. HDU 1078 FatMouse and Cheese(记忆化搜索)

    FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  9. ZOJ 1107 FatMouse and Cheese

    原题链接 题目大意:FM在一个街道n*n街道的(0,0)点,在每个网格里放着cheese,他要尽可能多的吃这些cheese.有两个规则:1)他跑的总距离不能超过k步:2)下一个节点的cheese的块数 ...

随机推荐

  1. free命令

    最近服务器总是出问题,研究一下free 以M的形式显示: 参数: Swap 是交换区信息, Swap空间的作用可简单描述为:当系统的物理内存不够用的时候,就需要将物理内存中的一部分空间释放出来,以供当 ...

  2. codeforce Group Photo 2 (online mirror version)

    题目大意: 有n个矩形在地上排成一列,不可重叠,已知他们的宽度w和高度h,现在使至多[n / 2]个矩形旋转90度,问最后可以用多小的矩形恰好覆盖这n个矩形,求满足条件的最小矩形面积. n, w, h ...

  3. C++ Vector 用法总结

    1, 头文件#include <vector> using namespace std; 2,定义与初始化 一般结合模板来使用 vector <Elem>           ...

  4. meta 标签 关键字 用处

    您的个人网站即使做得再精彩,在“浩瀚如海”的网络空间中,也如一叶扁舟不易为人发现,如何推广个人网站, 人们首先想到的方法无外乎以下几种: l 在搜索引擎中登录自己的个人网站 l 在知名网站加入你个人网 ...

  5. 38. Count and Say

    The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221 ...

  6. 关于display的那些事儿!

    关于display的那些事儿! display,display,display!嘿嘿嘿!display这一CSS属性,还是相当神奇的哦!给它设置不同的值,被修饰的标签相应的就随之变换了自身的属性特性, ...

  7. ruby-thread/process

    thread a = 1 threads = [] mutex = Mutex.new 5.times do threads << Thread.new do 1000.times do ...

  8. SQL注入脚本(基于时间)

    #encoding=utf-8 import httplib import time import string import sys import urllib header = {'Accept' ...

  9. P1003 越野跑【tyvj】

    /*=========================================================== P1003 越野跑 描述 Description 为了能在下一次跑步比赛中有 ...

  10. 转载——Python模拟登录代码

    ''' Created on 2014-2-20 @author: Vincent ''' import urllib.parse import gzip import json import re ...