305431: CF1030E. Vasya and Good Sequences
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Vasya and Good Sequences
题意翻译
【题目描述】 Vasya有n个64位二进制正整数,小R有一种魔法,它可以让一个二进制数的任意两位交换,比如它可以将7(...000111)变成11(...001011)或者22(...010110),等等。对于一个序列,如果Vasya可以通过对任意多个序列中的数(可以是0个)使用任意多次(可以是0次)这种魔法,使得序列中的所有数异或和得0,则称这是一个好的序列。给定n个数a_1,a_2,a_3...a_n,问有多少对(l,r),1<=l<=r<=n,使得a_l,a_l+1,...,a_r是好的序列。 【输入格式】 第一行一个正整数n 第二行n个正整数a_i。 【输出格式】 输出一行答案题目描述
Vasya has a sequence $ a $ consisting of $ n $ integers $ a_1, a_2, \dots, a_n $ . Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number $ 6 $ $ (\dots 00000000110_2) $ into $ 3 $ $ (\dots 00000000011_2) $ , $ 12 $ $ (\dots 000000001100_2) $ , $ 1026 $ $ (\dots 10000000010_2) $ and many others. Vasya can use this operation any (possibly zero) number of times on any number from the sequence. Vasya names a sequence as good one, if, using operation mentioned above, he can obtain the sequence with [bitwise exclusive or](https://en.wikipedia.org/wiki/Exclusive_or) of all elements equal to $ 0 $ . For the given sequence $ a_1, a_2, \ldots, a_n $ Vasya'd like to calculate number of integer pairs $ (l, r) $ such that $ 1 \le l \le r \le n $ and sequence $ a_l, a_{l + 1}, \dots, a_r $ is good.输入输出格式
输入格式
The first line contains a single integer $ n $ ( $ 1 \le n \le 3 \cdot 10^5 $ ) — length of the sequence. The second line contains $ n $ integers $ a_1, a_2, \dots, a_n $ ( $ 1 \le a_i \le 10^{18} $ ) — the sequence $ a $ .
输出格式
Print one integer — the number of pairs $ (l, r) $ such that $ 1 \le l \le r \le n $ and the sequence $ a_l, a_{l + 1}, \dots, a_r $ is good.
输入输出样例
输入样例 #1
3
6 7 14
输出样例 #1
2
输入样例 #2
4
1 2 1 16
输出样例 #2
4