CF1609F.Interesting Sections
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述

William has an array of non-negative numbers a1,a2,…,an. He wants you to find out how many segments l≤r pass the check. The check is performed in the following manner:
- The minimum and maximum numbers are found on the segment of the array starting at l and ending at r.
- The check is considered to be passed if the binary representation of the minimum and maximum numbers have the same number of bits equal to 1.

威廉有一个由非负整数组成的数组 a1,a2,…,an。他希望你计算出有多少个区间 l≤r 能通过如下检验:
- 在数组中从位置 l 开始、到位置 r 结束的该区间上,找出最小值和最大值;
- 若最小值与最大值的二进制表示中“1”的个数相等,则称该区间通过检验。
输入格式
The first line contains a single integer n (1≤n≤106), the size of array a.
The second line contains n integers a1,a2,…,an (0≤ai≤1018), the contents of array a.
第一行包含一个整数 n(1≤n≤106),表示数组 a 的大小。
第二行包含 n 个整数 a1,a2,…,an(0≤ai≤1018),表示数组 a 的元素。
输出格式
Output a single number — the total number of segments that passed the check.
输出一个数字——通过检查的线段总数。
输入输出样例
输入#1
5 1 2 3 4 5
输出#1
9
输入#2
10 0 5 7 3 9 10 1 6 13 7
输出#2
18
输入解题思路,AI测评打分。不知道怎么写?