Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Language: Joseph's Problem
Description Joseph likes taking part in programming contests. His favorite problem is, of course, Joseph's problem.
It is stated as follows.
Of course, all of you know the way to solve this problem. The solution is very short, all you need is one cycle: r := 0; Here "x mod y" is the remainder of the division of x by y, But Joseph is not very smart. He learned the algorithm, but did not learn the reasoning behind it. Thus he has forgotten the details of the algorithm and remembers the solution just approximately. He told his friend Andrew about the problem, but claimed that the solution can be found using the following algorithm: r := 0; Of course, Andrew pointed out that Joseph was wrong. But calculating the function Joseph described is also very interesting. Given n and k, find ∑1<=i<=n(k mod i). Input The input file contains n and k (1<= n, k <= 109). Output Output the sum requested. Sample Input 5 3 Sample Output 7 Source |
[Submit] [Go Back] [Status] [Discuss]
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator