CF1864H.Asterism Stream
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Bogocubic is playing a game with amenotiomoi. First, Bogocubic fixed an integer n , and then he gave amenotiomoi an integer x which is initially equal to 1 .
In one move amenotiomoi performs one of the following operations with the same probability:
- increase x by 1 ;
- multiply x by 2 .
Bogocubic wants to find the expected number of moves amenotiomoi has to do to make x greater than or equal to n . Help him find this number modulo 998244353 .
Formally, let M=998244353 . It can be shown that the answer can be expressed as an irreducible fraction qp , where p and q are integers and q≡0(modM) . Output the integer equal to p⋅q−1modM . In other words, output such an integer y that 0≤y<M and y⋅q≡p(modM) .
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t ( 1≤t≤100 ). The description of the test cases follows.
The only line of each test case contains one integer n ( 1≤n≤1018 ).
输出格式
For each test case, output a single integer — the expected number of moves modulo 998244353 .
输入输出样例
输入#1
7 1 4 8 15 998244353 296574916252563317 494288321850420024
输出#1
0 499122179 717488133 900515847 93715054 44488799 520723508
说明/提示
In the first test case, n≤x without any operations, so the answer is 0 .
In the second test case, for n=4 , here is the list of all possible sequences of operations and their probabilities:
- 1⟶+12⟶+13⟶+14 , the probability is 81 ;
- 1⟶×22⟶+13⟶+14 , the probability is 81 ;
- 1⟶+12⟶+13⟶×26 , the probability is 81 ;
- 1⟶×22⟶+13⟶×26 , the probability is 81 ;
- 1⟶+12⟶×24 , the probability is 41 ;
- 1⟶×22⟶×24 , the probability is 41 .
So the expected number of moves is 4⋅(3⋅81)+2⋅(2⋅41)=25≡499122179(mod998244353) .
In the third test case, for n=8 , the expected number of moves is 32137≡717488133(mod998244353) .
In the fourth test case, for n=15 , the expected number of moves is 409624977≡900515847(mod998244353) .