Description
X星球十分特殊,它的自转速度与公转速度相同,所以阳光总是以固定的角度照射。
最近,X星球为发展星际旅游业,把空间位置出租给Y国游客来晒太阳。每个租位是漂浮在空中的圆盘形彩云(圆盘与地面平行)。当然,这会遮挡住部分阳光,被遮挡的土地植物无法生长。
本题的任务是计算某个农场宜于作物生长的土地面积有多大。
Input
输入数据的第一行包含两个整数a, b,表示某农场的长和宽分别是a和b,此时,该农场的范围是由坐标(0, 0, 0), (a, 0, 0), (a, b, 0), (0, b, 0)围成的矩形区域。
第二行包含一个实数g,表示阳光照射的角度。简单起见,我们假设阳光光线是垂直于农场的宽的,此时正好和农场的长的夹角是g度,此时,空间中的一点(x, y, z)在地面的投影点应该是(x + z * ctg(g度), y, 0),其中ctg(g度)表示g度对应的余切值。
第三行包含一个非负整数n,表示空中租位个数。
接下来 n 行,描述每个租位。其中第i行包含4个整数xi, yi, zi, ri,表示第i个租位彩云的圆心在(xi, yi, zi)位置,圆半径为ri。
Output
要求输出一个实数,四舍五入保留两位有效数字,表示农场里能长庄稼的土地的面积。
Sample Input 1
10 10 90.0 1 5 5 10 5
Sample Output 1
21.46
Hint
HINT:时间限制:1.0s 内存限制:256.0MB
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.*;
class ArcRange{
double begin, end;
ArcRange(double begin, double end){
begin %= Math.PI*2;
end %= Math.PI*2;
if(begin<0)begin+=Math.PI*2;
if(end<0)end+=Math.PI*2;
this.begin = begin; this.end = end;
}
public String toString(){
return "Range:("+this.begin+","+this.end+")";
}
}
class Arcs{
double x, y, r;
boolean full;
List<ArcRange> ranges;
Arcs(double x, double y, double r){
this.x = x; this.y = y; this.r = r;
this.full = true;
this.ranges = new LinkedList<>();
//this.ranges.add(new ArcRange(0, Math.PI*2));
}
public String toString() {
StringBuffer str = new StringBuffer();
str.append("x:");
str.append(this.x);
str.append(" y:");
str.append(this.y);
str.append(" r:");
str.append(this.r);
str.append(" arcs:");
if (this.full) {
str.append("full");
}
else {
ListIterator<ArcRange> itr = this.ranges.listIterator();
while (itr.hasNext()) {
ArcRange r = itr.next();
str.append("(");
str.append(r.begin*180/Math.PI);
str.append(",");
str.append(r.end*180/Math.PI);
str.append(")");
}
}
return str.toString();
}
public void cutByRectWhenFull(double x, double y, double width, double height){
//this.x + this.r*cos(a) = x
//co