CF1905E.One-X

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

In this sad world full of imperfections, ugly segment trees exist.

A segment tree is a tree where each node represents a segment and has its number. A segment tree for an array of nn elements can be built in a recursive manner. Let's say function build(v,l,r)\operatorname{build}(v,l,r) builds the segment tree rooted in the node with number vv and it corresponds to the segment [l,r][l,r] .

Now let's define build(v,l,r)\operatorname{build}(v,l,r) :

  • If l=rl=r , this node vv is a leaf so we stop adding more edges
  • Else, we add the edges (v,2v)(v, 2v) and (v,2v+1)(v, 2v+1) . Let m=l+r2m=\lfloor \frac{l+r}{2} \rfloor . Then we call build(2v,l,m)\operatorname{build}(2v,l,m) and build(2v+1,m+1,r)\operatorname{build}(2v+1,m+1,r) .

So, the whole tree is built by calling build(1,1,n)\operatorname{build}(1,1,n) .

Now Ibti will construct a segment tree for an array with nn elements. He wants to find the sum of lca(S)\operatorname{lca}^\dagger(S) , where SS is a non-empty subset of leaves. Notice that there are exactly 2n12^n - 1 possible subsets. Since this sum can be very large, output it modulo 998244353998\,244\,353 .

lca(S)^\dagger\operatorname{lca}(S) is the number of the least common ancestor for the nodes that are in SS .

输入格式

Each test consists of multiple test cases. The first line contains a single integer tt ( 1t1031 \le t \le 10^3 ) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn ( 2n10182 \le n \le 10^{18} ) — the length of the array for which the segment tree is built.

输出格式

For each test case, output a single integer — the required sum modulo 998244353998\,244\,353 .

输入输出样例

  • 输入#1

    5
    2
    3
    4
    5
    53278

    输出#1

    6
    17
    36
    69
    593324855

说明/提示

In the first test case:

Let's look at all subsets of leaves.

  • lca({2})=2\operatorname{lca}(\{2\})=2 ;
  • lca({3})=3\operatorname{lca}(\{3\})=3 ;
  • lca({2,3})=1\operatorname{lca}(\{2,3\})=1 .

Thus, the answer is 2+3+1=62+3+1=6 .

In the second test case:

Let's look at all subsets of leaves.

  • lca({4})=4\operatorname{lca}(\{4\})=4 ;
  • lca({5})=5\operatorname{lca}(\{5\})=5 ;
  • lca({3})=3\operatorname{lca}(\{3\})=3 ;
  • lca({4,5})=2\operatorname{lca}(\{4,5\})=2 ;
  • lca({4,3})=1\operatorname{lca}(\{4,3\})=1 ;
  • lca({5,3})=1\operatorname{lca}(\{5,3\})=1 ;
  • lca({4,5,3})=1\operatorname{lca}(\{4,5,3\})=1 ;

Thus, the answer is 4+5+3+2+1+1+1=174+5+3+2+1+1+1=17 .

首页