poj 1005(π的反三角)

我太菜了  只能水水题维持生活这样子

I Think I Need a Houseboat

Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 113609   Accepted: 49040

Description

Fred Mapper is considering purchasing some land in Louisiana to build his house on. In the process of investigating the land, he learned that the state of Louisiana is actually shrinking by 50 square miles each year, due to erosion caused by the Mississippi River. Since Fred is hoping to live in this house the rest of his life, he needs to know if his land is going to be lost to erosion.

After doing more research, Fred has learned that the land that is being lost forms a semicircle. This semicircle is part of a circle centered at (0,0), with the line that bisects the circle being the X axis. Locations below the X axis are in the water. The semicircle has an area of 0 at the beginning of year 1. (Semicircle illustrated in the Figure.)

Input

The first line of input will be a positive integer indicating how many data sets will be included (N). Each of the next N lines will contain the X and Y Cartesian coordinates of the land Fred is considering. These will be floating point numbers measured in miles. The Y coordinate will be non-negative. (0,0) will not be given.

Output

For each data set, a single line of output should appear. This line should take the form of: “Property N: This property will begin eroding in year Z.” Where N is the data set (counting from 1), and Z is the first year (start from 1) this property will be within the semicircle AT THE END OF YEAR Z. Z must be an integer. After the last data set, this should print out “END OF OUTPUT.”

Sample Input

2
1.0 1.0
25.0 0.0

Sample Output

Property 1: This property will begin eroding in year 1.
Property 2: This property will begin eroding in year 20.
END OF OUTPUT.

Hint

1.No property will appear exactly on the semicircle boundary: it will either be inside or outside. 
2.This problem will be judged automatically. Your answer must match exactly, including the capitalization, punctuation, and white-space. This includes the periods at the ends of the lines. 
3.All locations are given in miles.

Source

Mid-Atlantic 2001

#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int demo(double x,double y){
    double area = acos(-1.0)*(x*x+y*y)/2;//所取π值巧妙
    return (int)ceil(area/50);
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        double x,y;
        cin>>x>>y;
        cout<<"Property "<<i<<": This property will begin eroding in year "<<demo(x,y)<<"."<<endl;
    }
    cout<<"END OF OUTPUT."<<endl;
}

原文地址:https://www.cnblogs.com/incep-sun/p/10285546.html

时间: 2024-11-06 16:19:18

poj 1005(π的反三角)的相关文章

poj 1005:I Think I Need a Houseboat(水题,模拟)

I Think I Need a Houseboat Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 85149   Accepted: 36857 Description Fred Mapper is considering purchasing some land in Louisiana to build his house on. In the process of investigating the land,

php for循环出的正三角和反三角

//打印正三角:9*5 层数既高度决定宽度既底长: for($i=1;$i<=5;$i++){ for($j=1;$j<=5-$i;$j++){ echo " "; } for($k=1;$k<=$i;$k++){ echo "* "; } for($j=1;$j<$i;$j++){ echo "* "; } echo "\n";} //反三角echo "\n";for($i=1;$

POJ 3187 杨辉三角+枚举排列 好题

如果给出一个由1~n组成的序列,我们可以每相邻2个数求和,得到一个新的序列,不断重复,最后得到一个数sum, 现在输入n,sum,要求输出一个这样的排列,如果有多种情况,输出字典序最小的那一个. 刚开始我是直接搜,tle了 然后就开始找最初的序列和最终的和有什么关系 因为最终的和sum一定是等于若干个a[1],若干个a[2],...,若干个a[n]的和 即sum=p1*a1+p2*a2+...+pn*an 所以我们只要求出数组a的系数,n个p即可. 然后发现,和杨辉三角有很大的关系. 如果杨辉三

Poj 1005

刚开始的时候下意识想把坐标半径和每一年淹没的半径求出来做比较-- 1 #include<iostream> 2 #define pi 3.14159265 3 using namespace std; 4 int main(){ 5 int N; 6 double x,y; 7 int year; 8 cin>>N; 9 for(int i=0;i<N;i++){ 10 cin>>x>>y; 11 year=pi*(x*x+y*y)/100+1; 12

poj 1005 I Think I Need a Houseboat

1 #include <iostream> 2 using namespace std; 3 const double pi = 3.1415926535; 4 5 int main() 6 { 7 int t,time = 0;; 8 double x,y; 9 cin >> t; 10 while(t--) 11 { 12 ++time; 13 cin >> x >> y; 14 double area = pi*(x*x + y*y); 15 int

POJ 1005 解题报告

题意就是,有一块半圆形区域,从0,0点开始向四周扩展,每年扩展50.0面积(单位统一不用考虑). 计算给定点在第几年结束之前被圆形区域覆盖. 我的思路: 1.计算以给定点到原点长度的半径做半圆的面积. 2.除以50.0,所得结果加1,就是所求 PI取3.14159265 #include<iostream> #include<string> using namespace std; int main() { double x, y; int n; const double PI =

POJ 1005 I Think I Need a Houseboat 水

 I Think I Need a Houseboat Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 92807   Accepted: 40360 Description Fred Mapper is considering purchasing some land in Louisiana to build his house on. In the process of investigating the lan

反三角,空格一个太长了。。。用的..(两个句号英文字符)代替。

for (int h = 1; h <= 10; h++) { for (int kg = 2; kg <= h; kg++) { Console.Write(".."); } for (int xing = 10; xing >= h; xing--) { Console.Write("※"); } Console.Write("\n"); }

POJ题目Java代码(一)

POJ 1001 Exponentiation import java.math.BigDecimal; import java.util.Scanner; public class Poj1001 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()){ BigDecimal bigDecimal = new BigDecimal(sc.next())