• Poj_1005_I Think I Need A HouseBoat


    一、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.”
    二、问题分析
           虽然小弟的英语水平是个半吊子,但这题的意思也太***难以理解了吧。开始的时候我完全理解错了,谢谢几位大哥的留言呐。大体意思:半圆表示一块面积可扩展的区域,开始时,面积是0,在(0,0)处开始以每年50平方米的速度同样呈半圆扩展,输入一个正整数N,然后输入N对坐标,对于每一对坐标值:求出面积扩展到该点的年数,坐标值单位为英里。
          有了中文的翻译这题几乎就没什么了,值得一提的还是精度的问题。由于此题没有什么值得分析的东西,所以就提一些需要注意的地方。
           BigDecimal类:不可变的任意精度的整数。BigDecimal 类提供以下操作:算术、标度操作、舍入、比较、哈希算法和格式转换。toString() 方法提供BigDecimal 的规范表示形式。 这里用到了它的setScale(0, RoundingMode.UP)方法,返回一个 BigDecimal,其标度为指定值,其非标度值通过此BigDecimal 的非标度值乘以或除以十的适当次幂来确定,以维护其总值。如果该操作减少标度,则非标度值必须被除(而不是乘),并且该值可以更改;在这种情况下,将指定的舍入模式应用到除法中。官方解释如上,但小弟至今不明白标度和非标度是什么意思。通俗点讲,第一个参数说明你要多少位小数,第二个参数是在得到第一个参数的值是所使用的舍入规则。就如上面方法中的参数所示,0表示要得到的数是整数,RoundingMode.Up表示远离零方向舍入的舍入模式。RoundingMode是为可能丢弃精度的数值操作指定一种舍入行为,是枚举类型。比如,如果原来的值是0.5,用了这个方法之后,值就变为1.特别注意,舍入是与你所要求的精度有关的。如果你要得精度为1,后面参数的不变,那么值还是0.5.因为0.5已经满足了你的精度要求了,不需要后面的舍入规则了。
          这道题题没什么其他知识了,就是题目晦涩难懂。






    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    Day12——提权学习之第三方软件Radmin提权
    Day11——提权学习之第三方软件VNC提权
    Day10——提权学习之第三方软件FlashFXP及pcAnywhere提权
    Day9——提权学习之第三方软件FileZilla提权
    Day8——提权学习之第三方软件G6-FTP提权
    Day7——提权学习之第三方软件serv-u提权
    Day6——提权学习之Oracle数据库提权学习总结
    Memcached 未授权访问漏洞 CVE-2013-7239
    恭喜tes获得夏季赛冠军
    有关xss的小日记
  • 原文地址:https://www.cnblogs.com/AndyDai/p/4734225.html
Copyright © 2020-2023  润新知