测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A11473. Magic Forest

编程题 普及/提高-

题目描述

Imp is in a magic forest, where xorangles grow (wut?)

![](/uploads/acgo/image/fcbad1aad6eb639e_33189db80ec5.jpeg)A xorangle of order $n$ is such a non-degenerate triangle, that lengths of its sides are integers not exceeding $n$ , and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order $n$ to get out of the forest.

Formally, for a given integer $n$ you have to find the number of such triples $(a,b,c)$ , that:

- $1<=a<=b<=c<=n$ ;
- ![](/uploads/luogu/CF922B/e65927e7d4505d57752956035449f810615b89fe_7f98af1dea57.png), where ![](/uploads/luogu/CF922B/7f1c9cbc3c887d7630734a437576c704fecc514a_b036b1d8f612.png) denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers $x$ and $y$ .
- $(a,b,c)$ form a non-degenerate (with strictly positive area) triangle.

输入格式

The only line contains a single integer $n$ $(1<=n<=2500)$ .

输出格式

Print the number of xorangles of order $n$ .

输入输出样例

输入 #1
6
输出 #1
1
输入 #2
10
输出 #2
2

说明/提示

The only xorangle in the first sample is $(3,5,6)$ .
上一题 去做题 下一题