摘要: 题意就是标题。 思路: 对于每个数 a 算出 1~a 的所有因数和sum(a),输出sum(b)-sum(a-1)。 关键在于如何求出 sum。 首先发现因数∈ 1 ≤ i ≤ n ,每个因数在区间[1,n]内的出现次数(不考虑4=2*2这样因数重复出现,这种情况2只算出现一次)等于 n/i (向下 阅读全文
posted @ 2018-08-16 21:14 llllrj 阅读(518) 评论(0) 推荐(0) 编辑
摘要: upper_bound( begin,end,num):从数组的begin位置到end-1位置二分查找第一个大于num的数字,找到返回该数字的地址,不存在则返回end。通过返回的地址减去起始地址begin,得到找到数字在数组中的下标。 阅读全文
posted @ 2018-08-16 08:59 llllrj 阅读(4131) 评论(0) 推荐(0) 编辑
摘要: There is a class consisting of n students, in which each one has a number representing his/her personality. The teacher gives the students a new assig 阅读全文
posted @ 2018-08-16 00:44 llllrj 阅读(320) 评论(0) 推荐(0) 编辑