We will construct an infinitely long string from two short strings: A = "^__^" (four characters), and B = "T.T" (three characters). Repeat the following steps:
- Concatenate A after B to obtain a new string C. For example, if A = "^__^" and B = "T.T", then C = BA = "T.T^__^".
- Let A = B, B = C -- as the example above A = "T.T", B = "T.T^__^".
Input
The input contains multiple test cases, each contains only one integer N (1 <= N <= 2^63 - 1). Proceed to the end of file.
Output
For each test case, print one character on each line, which is the N-th (index begins with 1) character of this infinite string.
Sample Input
1 2 4 8
Sample Output
T . ^ T
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
long long int n;
int main()
{
char base[]="T.T^__^\0";
long long f[88];
f[0]=7;
f[1]=10;
for(int i=2;i<88;i++)
f[i]=f[i-1]+f[i-2];
while(scanf("%lld",&n)!=EOF)
{
while(n>7)
{
int i=0;
while(i<88&&f[i]<n)
i++;
n-=f[i-1];
}
printf("%c\n",base[n-1]);
}
return 0;
}
1万+




被折叠的 条评论
为什么被折叠?



