#P3312. Sum of Common Divisor Sums in a Grid

    ID: 16569 Type: Default 1000ms 256MiB

Sum of Common Divisor Sums in a Grid

Sum of Common Divisor Sums in a Grid

Consider an n × m table where the value at cell (i, j) (with 1 ≤ i ≤ n and 1 ≤ j ≤ m) is defined as the sum of all natural numbers that can divide both i and j evenly. In other words, if we denote the value at cell (i, j) by \(V(i,j)\), then

[ V(i,j) = \sum_{d \mid i ; \text{and} ; d \mid j} d = \sigma(\gcd(i,j)) ]

Given three integers n, m, and a, your task is to compute the sum of all numbers in the table that are less than or equal to a.

inputFormat

The input consists of a single line containing three positive integers n, m, and a separated by spaces.

\(1 \le n, m \le 10^3\) (for example) and a is a positive integer.

outputFormat

Output a single integer -- the sum of all table values that are not greater than a.

sample

2 2 3
6