CF691E.Xor-sequences

普及+/提高

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given n integers _a_1,  _a_2,  ...,  a__n.

A sequence of integers _x_1,  _x_2,  ...,  x__k is called a "xor-sequence" if for every 1  ≤  i  ≤  k - 1 the number of ones in the binary representation of the number x__i x__i  +  1's is a multiple of 3 and for all 1 ≤ i ≤ k. The symbol is used for the binary exclusive or operation.

How many "xor-sequences" of length k exist? Output the answer modulo 109 + 7.

Note if a = [1, 1] and k = 1 then the answer is 2, because you should consider the ones from a as different.

给你 $ n $ 个整数 $ a_1,,a_2,,\dots,,a_n $。

一个整数序列 $ x_1,,x_2,,\dots,,x_k $ 被称为“异或序列”(xor-sequence),当且仅当对每个 $ 1\le i\le k-1 $,数 $ x_i \oplus x_{i+1} $ 的二进制表示中 1 的个数是 3 的倍数,且对所有 $ 1\le i\le k $,均有 $ x_i \in {a_1,,a_2,,\dots,,a_n} $。其中符号 $ \oplus $ 表示二进制按位异或运算。

长度为 $ k $ 的“异或序列”共有多少个?请输出答案对 $ 10^9 + 7 $ 取模的结果。

注意:若 $ a = [1,,1] $ 且 $ k = 1 $,则答案为 2,因为需将 $ a $ 中的两个 1 视为不同的元素。

输入格式

The first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 1018) — the number of given integers and the length of the "xor-sequences".

The second line contains n integers a__i (0 ≤ a__i ≤ 1018).

第一行包含两个整数 nn 和 kk(1≤n≤1001 \leq n \leq 100,1≤k≤10181 \leq k \leq 10^{18})—— 分别表示给定整数的个数以及“异或序列”(xor-sequence)的长度。

第二行包含 nn 个整数 aia_i(0≤ai≤10180 \leq a_i \leq 10^{18})。

输出格式

Print the only integer c — the number of "xor-sequences" of length k modulo 109 + 7.

输出唯一的整数 cc —— 长度为 kk 的“异或序列”(xor-sequences)的个数,对 109+710^9 + 7 取模。

输入输出样例

  • 输入#1

    5 2
    15 1 2 4 8

    输出#1

    13
  • 输入#2

    5 1
    15 1 2 4 8

    输出#2

    5

输入解题思路,AI测评打分。不知道怎么写?

首页