一、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已经满足了你的精度要求了,不需要后面的舍入规则了。

      这道题题没什么其他知识了,就是题目晦涩难懂。












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

最新文章

  1. 再谈SQL Server中日志的的作用
  2. Notes: select选择框
  3. 三言两语之js事件、事件流以及target、currentTarget、this那些事
  4. 【 D3.js 入门系列 --- 7 】 理解 update, enter, exit 的使用
  5. SharePoint 2013 新建项目字段自动加载上次保存值
  6. SQL Server 2012实施与管理实战指南(笔记)——Ch3Alwayson可用组
  7. 部署openssh服务器
  8. nginx日志中文变成类型\xE9\xA6\x96\xE9\xA1\xB5-\xE6\x8E\xA8\xE8\x8D\x90的东西
  9. 1362. Classmates 2
  10. Qt msgBox 快捷版
  11. Jenkins Job 自杀 groovy
  12. Ubuntu server解决不能访问外网问题
  13. Android 获取本地图片
  14. Mac 系统下将普通文件变为可执行文件
  15. selenium python (十一)alert/confirm/prompt的处理(js中的弹出框)
  16. PHP流程控制(一)
  17. OC基础 可变数组与不可变数组的使用
  18. Android中典型的ROOT原理(5)
  19. bash 基础命令
  20. 『流畅的Python』第13章:正确重载运算符

热门文章

  1. [ACM] HDU 1533 Going Home (二分图最小权匹配,KM算法)
  2. 从symbol link和hard link 到 unlink函数的一点记录
  3. maven 配置: 修改默认的 .m2仓库 默认存储路径.
  4. Webpack探索【8】--- 模块热替换详解
  5. 我的Java开发学习之旅------>Java NIO 报java.nio.charset.MalformedInputException: Input length = 1异常
  6. SQL 中GROUP BY 、ROLLUP、CUBE 关系和区别
  7. DOM的介绍
  8. java多线程系列 JUC原子类 CAS及原子类
  9. 学习 Promise,掌握未来世界 JS 异步编程基础
  10. PS图片透明处理方法