题目链接:http://codeforces.com/contest/404/problem/B?csrf_token=6292hf3e1h4g5e0d16a996ge6bgcg7g2 解题报告:一个正方形的跑道,边长是a,然后教练给运动员一个规定,每跑d米就额外补充一次饮料,然后输入一个n,表示一共将补充n次,比赛的出发点是(0,0), 也就是左下角的那个点,然后让你求出每次补充饮料的坐标. 本来看起来应该挺简单的一个模拟题,结果没想到一波三折,哎,技术问题啊.首先要注意的就是它规定的是精确到…
前文 的最后给出了玉伯的一道课后题,今天我们来讲讲这题的思路. 题目是这样的: Number.MAX_VALUE + 1 == Number.MAX_VALUE; Number.MAX_VALUE + 2 == Number.MAX_VALUE; ... Number.MAX_VALUE + x == Number.MAX_VALUE; Number.MAX_VALUE + x + 1 == Infinity; ... Number.MAX_VALUE + Number.MAX_VALUE ==…
背景 在博客 恶心的0.5四舍五入问题 一文中看到一个关于 0.5 不能正确的四舍五入的问题.主要说的是 double 转换到 BigDecimal 后,进行四舍五入得不到正确的结果: public class BigDecimalTest { public static void main(String[] args){ double d = 301353.05; BigDecimal decimal = new BigDecimal(d); System.out.println(decima…
java操作Excel处理数字类型的精度损失问题验证: 场景: CELL_TYPE_NUMERIC-->CELL_TYPE_STRING--->CELL_TYPE_NUMERIC POI版本:poi-3.10.1poi-3.9 Code: package poi; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.i…
// Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问题的思路: // // 第一个假设a字符串和b字符串相等,说直接YES // 假设b串全是0,直接YES // 注意到a串有一个性质,1的个数不会超过本身的加1. // a有个1的上限设为x,b有个1的个数设为y,则假设x < y // 那么直接NO. // // 如今普通情况下.就是模拟啦,找到a…
/** * 加法运算,避免数据相加小数点后产生多位数和计算精度损失. * * @param num1加数1 | num2加数2 */ function numAdd(num1, num2) { var baseNum, baseNum1, baseNum2; try { baseNum1 = num1.toString().split(].length; } catch (e) { baseNum1 = ; } try { baseNum2 = num2.toString().split(].l…
浮点数会有精度损失这个在上大学的时候就已经被告知,但是至今完全没有想明白其中的原由,老师讲的时候也是一笔带过的,自己也没有好好琢磨.终于在工作的时候碰到了,于是google了一番. 问题: 对两个double类型的值进行运算,有时会出现结果值异常的问题.比如: 1 System.out.println(19.99+20); 2 System.out.println(1.0-0.66); 3 System.out.println(0.033*100); 4 System.out.println(1…
Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Description Input Output Print exactly one integer — the beauty of the product of the strings. Sample Input 3aba Sample Output 3 题解:这个题的思维难度其实不大,需要维护什么东西很容易想到,或…
Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Input The first line contains a single integer nn (2≤n≤150000) — the number of kittens. Each of the following n−1lines contains integers xi and yi (1≤xi,…
Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input Output The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwis…