ZOJ 1049 &&HDU 1065 I Think I Need a Houseboat

来源:互联网 发布:基恩士plc编程手册 编辑:程序博客网 时间:2024/05/20 10:13

链接:click here

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.)

题意:由坐标 (0,0) 开始,以半圆为形状每年侵蚀50 平方 miles ,问你从 (0,0) 开始到 (x,y) 结束需要多长时间 相当于给一个岛的腐蚀距离时间,给你点的坐标,问你多久被腐蚀。

思路:简单的数学题,不解释了。

代码:

#include <stdio.h>#include <string.h>#include <math.h>#include <iostream>#include <algorithm>using namespace std;const int Inf=0x3f3f3f3f;const int maxn=1000;const double eps=1e-6;const double pi=acos(-1.0);int n,m,i,j;int cost[maxn][maxn];double  vis[maxn];double s(double x,double y){    return ((x*x+y*y)*pi)/2.0;}int main(){    int ncase,i,j=1;    double x,y;    cin>>ncase;    while(ncase--)    {        int b;        scanf("%lf%lf",&x,&y);        printf("Property %d: This property will begin eroding in year %d.\n",j++,(int )ceil((s(x,y)/50)));    }      printf("END OF OUTPUT.\n");}


0 0
原创粉丝点击