《数据结构编程实验》 1.3.1I Think I Need a Houseboat

来源:互联网 发布:卡巴斯基软件下载 编辑:程序博客网 时间:2024/05/16 09:08


题目大意:

  一个每年增大50平方英里的半圆形,给出n个点,计算每个点分别在第几年会被半圆形覆盖。


题目地址:

  POJ  1005 ZOJ  1049 UVA  2363


题解:

  计算点所在半圆的面积,除以50后向上取整得到年数。


#include <iostream>#include <cstdio>using namespace std;int main(){    int n,i,ans;    double x,y,s;    scanf("%d",&n);    for (i=0;i<n;i++)    {        scanf("%lf%lf",&x,&y);        s=(x*x+y*y)*3.14159265/2;        ans=s/50+1;        printf("Property %d: This property will begin eroding in year %d.\n",i+1,ans);    }    printf("END OF OUTPUT.\n");    return 0;}


0 0
原创粉丝点击