No.2129 Perfect Binary Tree...?
タグ : / 解いたユーザー数 14
作問者 : 👑
PCTprobability
👑 Problem Statement
There is an undirected graph $G$ with $2^N-1$ vertices and $2^N-1$ edges.
The $1$-st edge of $G$ connects vertex $u$ and vertex $v$, and the $x$-th edge $(2\le x\le 2^N-1)$ connects vertex $\lfloor x/2 \rfloor$ and vertex $x$.
Let $d(i,j)$ be the distance between vertex $i$ and vertex $j$ on $G$.
Find $\displaystyle \sum_{1\le i< j\le 2^N-1} d(i,j)$ modulo $998244353$.
Here, $\lfloor x/2 \rfloor$ denotes the largest integer less than or equal to $x/2$.
Constraints
Input
$N$ $u$ $v$
Output
Print $\displaystyle \sum_{1\le i< j\le 2^N-1} d(i,j)$ modulo $998244353$.
Sample
Sample 1
Input
2 10 11
Output
3
There are edges between vertex $2$ and vertex $3$, vertex $1$ and vertex $2$, and vertex $1$ and vertex $3$.
Thus, $d(i,j)=1$ for $1\le i < j\le 3$. Therefore, print $3$.
Sample 2
Input
3 1 1
Output
48
It is possible that $u=v$.
Sample 3
Input
8 1101 101
Output
314684
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。