OPMODULO - "Operation - Modulo"
Mahmud solved some easy math problems from SPOJ and called himself king of number theory. GodFather GodMATHer Rashad heard it and got angry, so he kidnapped Mahmud. Rashad gave him a task called "Operation - Modulo". Mahmud must solve this task, you know what will happen otherwise ;(. In the Operation - Modulo, we define a function f(n) = (n mod 1) + (n mod 2) + (n mod 3) + ... + (n mod n), where n mod x denotes the remainder when dividing n by x. Rashad interests with integers n such that f(n) = f(n - 1), so he gave Mahmud two numbers L and R, and demands him to find the sum of all integers n such that L ≤ n ≤ R and f(n) = f(n - 1).
Input
First and the only line of input contains two positive integers, L and R (1 ≤ L ≤ R ≤ 1018).
Output
Print the demanded sum in one line.
Example
Input: 1 3 Output: 3
Note: I hope you proved your solution before submitting it :)
hide comments
utkarsh051:
2024-07-18 09:53:45
I am getting runtime error each time Iam trying to submit it with below code. Can someone help me with this?
|
|
mushfiq123:
2024-03-25 17:19:09
Good question, but more test case would have been nice, don't listen to other comments, think and try to find solution by printing values of n, some might think it'll overflow or has to be moduled, but when u find it it's piece of cake |
|
mradul_2212:
2023-09-05 14:04:56
worst coding learning site.....atleast give 4-5 test cases ..so that we understand exactly the expectation of the question...there is so much ambiguity in this question....as it demands the sum of all n...but in the test case output is all n+(n-1) |
|
manmeet_muskan:
2022-12-05 07:58:31
can anybody tell me the answer for 1 16
|
|
the_naughtycat:
2022-11-09 15:20:45
D:\c++ code\luvQuestions\printModuloM.cpp
|
|
rav01:
2022-08-27 15:00:53
look for pattern by printing values of n. |
|
ardur:
2022-08-12 03:11:27
@sachin_0001
|
|
roshanpurohit:
2022-03-12 09:07:14
isn't f(0) undefined? how come f(1)=f(0) holds?
|
|
mjjishan:
2022-02-08 18:50:12
I'm getting Runtime errors :(
|
|
deependra1037:
2021-08-21 05:15:12
I found the sequence but it is showing the wrong answer on submission while i have provided custom inputs and it is working good on my test cases.
|
Added by: | Barish |
Date: | 2018-03-15 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | Deep places of my brain |