Trial Problem
Time limit1sMemory limit128 MB
Given n up to 2010, compute the final value of the triple loop that adds each floored s*k/i term modulo 2010.
- Level
Medium7 of 10
- Topics
- Math, Number theory
- Solved
- No attempts yet
Problem
You are given an integer n. Run the following C code exactly as written. After all three nested loops finish, determine the value of the variable ret.
int ret = 0;
for(int s = 1; s<=n; s++) {
for(int k = s; k<=n; k++) {
for(int i = k; i<=n; i++) {
ret = (ret+s*k/i)%2010;
}
}
}
Here s*k/i is C integer division (it discards the fractional part), and because ret is reduced modulo 2010 on every iteration, ret always stays between 0 and 2009 inclusive.
Input
The first and only line of input contains the integer n ().
Output
Print the final value of the variable ret on a single line after the loop has fully executed.