码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-01-27 00:38:36      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:acm   数学   

链接: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");
}






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

标签:acm   数学   

原文地址:http://blog.csdn.net/u013050857/article/details/43165453

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!