問題一覧 > 通常問題

No.1800 Random XOR

レベル : / AI推定難易度 : 700 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 176
作問者 : NatsubiSogan / テスター : penguinman Cyanmond
お気に入りにしたユーザー ProblemId : 7036 / 自分の提出
問題文最終更新日: 2021-11-17 20:13:34
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 326 (順位表) の他の問題:

Problem Statement

You are given positive integers $N,M$.

A sequence $A=(A_1,A_2,\dots,A_N)$ is determined as follows.

  • For each $i$ $(1 \leq i \leq N)$, $A_i$ is chosen uniformly at random from the integers between $0$ and $2^M-1$, inclusive. This choice is independent of the other elements.

Output the expected value of $A_1 \oplus A_2 \oplus \dots \oplus A_N$ modulo $\bmod 10^9+7$ (see Notes). Here, $a \oplus b$ denotes the bitwise XOR of $a,b$.

Notes

Under these constraints, the expected value to be found is a rational number. Writing it as an irreducible fraction $\displaystyle \frac{P}{Q}$, it can be proved that $Q \not \equiv 0 \pmod{10^9+7}$. Then there is a unique integer $R$ between $0$ and less than $10^9+7$ such that $R \times Q \equiv P \pmod{10^9+7}$; output this $R$.

Input

$N$ $M$
  • All input values are integers.
  • $1 \leq N,M \leq 10^{18}$

Output

Output the expected value of $A_1 \oplus A_2 \oplus \dots \oplus A_N$ modulo $\bmod 10^9+7$.

Print a newline at the end.

Sample

Sample 1
Input
2 1
Output
500000004
  • When $A_1=0,\ A_2 = 0$: $A_1 \oplus A_2 = 0$
  • When $A_1=0,\ A_2 = 1$: $A_1 \oplus A_2 = 1$
  • When $A_1=1,\ A_2 = 0$: $A_1 \oplus A_2 = 1$
  • When $A_1=1,\ A_2 = 1$: $A_1 \oplus A_2 = 0$

Therefore, the expected value to be found is $\displaystyle \frac{1}{2}$. Expressed modulo $\bmod 10^9+7$, this is $500000004$.

Sample 2
Input
314159265358979323 271828182845904523
Output
803876782

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。