#P6034. Modulo XOR Summation

    ID: 19258 Type: Default 1000ms 256MiB

Modulo XOR Summation

Modulo XOR Summation

Given a non-negative integer n, count the number of ordered pairs of non-negative integers (a, b) such that:

$$\sum_{a=0}^{n} \sum_{b=a+1}^{n} \left[ a \equiv b \pmod{a \oplus b} \right]$$

That is, count the number of pairs (a, b) with 0 \leq a < b \leq n satisfying the condition ab(modab),a \equiv b \pmod{a \oplus b},

where (a \oplus b) denotes the bitwise XOR of a and b, and the notation (a \equiv b \pmod{m}) means that (m) divides (b - a).

You are to output the count of such ordered pairs.

inputFormat

The input consists of a single integer n on a single line.

Constraints: 0 \le n \le 10^3. A brute-force solution is acceptable under these constraints.

outputFormat

Output a single integer representing the number of valid pairs (a, b) that satisfy the condition.

sample

0
0