I Think I Need a Houseboat问题

Time Limit: 1000MS

Memory Limit: 10000K

Total Submissions: 107313

Accepted: 46580

FredMapper is considering purchasing some land in Louisiana to build his house on.In the process of investigating the land, he learned that the state ofLouisiana is actually shrinking by 50 square miles each year, due to erosioncaused by the Mississippi River. Since Fred is hoping to live in this house therest of his life, he needs to know if his land is going to be lost toerosion. After doing more research, Fred has learned that the land that isbeing 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 belowthe X axis are in the water. The semicircle has an area of 0 at the beginningof year 1. (Semicircle illustrated in the Figure.) 

Input

The first line of input will be a positive integer indicating how manydata sets will be included (N). Each of the next N lines will contain the X andY Cartesian coordinates of the land Fred is considering. These will be floatingpoint 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 shouldtake 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 from1) this property will be within the semicircle AT THE END OF YEAR Z. Z must bean 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 willeither 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 theperiods at the ends of the lines. 

3.All locations are given in miles.

#include<stdio.h>

int main()

{

    int N,Z=0,n=0;       //N表示测试用例的个数,Z表示需要的年数,n表示财产为第几个

    float x,y;    //x为横坐标,y为纵坐标

    int flag=1;  //flag是一个标志,赋初值为1,测试用例结束后赋为0,结束循环

    scanf("%d",&N);      //输入N

    scanf("%f%f",&x,&y); //输入横纵坐标

    while(flag)

    {

       if(((100*Z)/3.14-(x*x+y*y))>=0)   

       {      //判断,当半圆的半径大于等于输入的点到原点的距离时,n加一个,输出Z,N减少一个

           n=n+1;

           printf("Property %d: Thisproperty will begin eroding in year %d.\n",n,Z);       //输出

           N=N-1;

           if(N==0)

           {          //判断,如果N=0,赋flag=0,跳出循环,结束

              flag=0;

              printf("END OFOUTPUT.\n");

              break;

           }

           scanf("%f%f",&x,&y);     //如果N不等于0,继续输入

       }

       else       //当半圆的半径小于输入的点到原点的距离时,Z加1,继续循环,直到找到满足条件的Z

       {

           Z=Z+1;

       }

    }

    return 0;

}

 

全部评论

相关推荐

最近和朋友聊天,她说了句让我震惊的话:"我发现我连周末点外卖都开始'最优解'了,一定要赶在高峰期前下单,不然就觉得自己亏了。"这不就是典型的"班味入侵"吗?工作思维已经渗透到生活的方方面面。
小型域名服务器:啊?我一直都这样啊?我还以为是我爱贪小便宜呢?每次去实验室都得接一杯免费的开水回去,出门都得规划一下最短路径,在宿舍就吃南边的食堂,在实验室就吃北边的食堂,快递只有顺路的时候才取。
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务