#P16502. [GKS 2015 #A] Googol String

    ID: 16479 Type: RemoteJudge 1000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>递推2015分治Google Kick Start

[GKS 2015 #A] Googol String

题目描述

A "0/1 string" is a string in which every character is either 0 or 1. There are two operations that can be performed on a 0/1 string:

  • switch: Every 0 becomes 1 and every 1 becomes 0. For example, "100" becomes "011".
  • reverse: The string is reversed. For example, "100" becomes "001".

Consider this infinite sequence of 0/1 strings:

S0="S_0 = ``"

S1=0"S_1 = ``0"

S2=001"S_2 = ``001"

S3=0010011"S_3 = ``0010011"

S4=001001100011011"S_4 = ``001001100011011"

...

$S_N = S_{N-1} + ``0" + \textbf{switch}(\textbf{reverse}(S_{N-1}))$.

You need to figure out the Kth character of SgoogolS_{\text{googol}}, where googol = 1010010^{100}.

输入格式

The first line of the input gives the number of test cases, TT. Each of the next TT lines contains a number KK.

输出格式

For each test case, output one line containing "Case #x: yy", where xx is the test case number (starting from 11) and yy is the Kth character of SgoogolS_{\text{googol}}.

4
1
2
3
10
Case #1: 0
Case #2: 0
Case #3: 1
Case #4: 0

提示

Limits

1T1001 \le T \le 100.

Small dataset (Test Set 1 - Visible)

1K1051 \le K \le 10^5.

Large dataset (Test Set 2 - Hidden)

1K10181 \le K \le 10^{18}.