QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#18398. MEX of MEX

統計

$mex(S)$ is the smallest non-negative integer that is not contained in the set $S$.

A substring of a string $X$ is a contiguous part of $X$ with length $0$ or greater.

A string of length $0$ or greater where 'M', 'E', and 'X' appear in alternating order is called a MEX string. For example, "", "M", "MEX", and "MEXME" are MEX strings, while "MMEX", "EXM", and "EX" are not.

The score of a set $S$ consisting of strings is defined as $mex(|k| : k \in S)$.

Given the length $N$ of a MEX string $M$, output the maximum possible score of a set formed by choosing non-overlapping substrings of $M$ that are themselves MEX strings. That the substrings of $M$ are non-overlapping means that every character of $M$ is contained in at most one substring.

Input

The first line contains the number of test cases $T$ ($1 \leq T \leq 100\,000$).

Each test case consists of a single line containing the length $N$ of the MEX string $M$ ($1 \leq N \leq 10^{18}$).

Output

For each test case, output the maximum score of the set.

Examples

Input 1

5
1
3
4
8
324513245432

Output 1

2
2
3
4
805621

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.