0002农场阳光

该博客介绍了如何计算在X星球上,由于漂浮的圆盘形彩云(租位)遮挡阳光后,农场适宜作物生长的土地面积。输入包括农场的长宽、阳光照射角度和彩云数量及位置,输出为保留两位有效数字的农场未被遮挡土地面积。
摘要由CSDN通过智能技术生成

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值