hduoj1065 I Think I Need a Houseboat
阿新 • • 發佈:2019-01-05
四個坑點:
1、pi 必須用 3.1415926.
PS: pi 最精準的表示是 acos(-1). 標頭檔案 math.h
2、每隔一年侵蝕的面積為50平方英里。如果整除50,當作下一年的。eg:如果面積擴充到40, 是第一年;面積擴充到50(邊界線),是第二年;面積擴充到60, 是第二年。
PS:邊界線要分清屬於哪一塊。
3、x, y要用double,不能用float。題目中給的說明是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
PS:做題遇到能用double的,儘量不用float。特別是對精度可能有要求的題。
4、強制型別轉換的使用。 return (int)area / 50 + 1; 會WA;return (int) (area / 50 + 1);就AC。
PS:強制型別轉換要在計算完畢所有的之後,再轉換。不要提前轉換,導致精度受損。