CF1609F.Interesting Sections

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

William has an array of non-negative numbers a1,a2,…,ana_1, a_2, \dots, a_n. He wants you to find out how many segments l≤rl \le r pass the check. The check is performed in the following manner:

  1. The minimum and maximum numbers are found on the segment of the array starting at ll and ending at rr.
  2. 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,…,ana_1, a_2, \dots, a_n。他希望你计算出有多少个区间 l≤rl \le r 能通过如下检验:

  1. 在数组中从位置 ll 开始、到位置 rr 结束的该区间上,找出最小值和最大值;
  2. 若最小值与最大值的二进制表示中“1”的个数相等,则称该区间通过检验。

输入格式

The first line contains a single integer nn (1≤n≤1061 \le n \le 10^6), the size of array aa.

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (0≤ai≤10180 \le a_i \le 10^{18}), the contents of array aa.

第一行包含一个整数 nn(1≤n≤1061 \le n \le 10^6),表示数组 aa 的大小。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(0≤ai≤10180 \le a_i \le 10^{18}),表示数组 aa 的元素。

输出格式

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测评打分。不知道怎么写?

首页