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^__^".

Your task is to find out the n-th character of this infinite string.


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

题意:不断循环   找出第N个字母是什么  输出

要用unsigned long long

#include <iostream>
#include <stdio.h>
#include <string.h> using namespace std; unsigned long long a[];
unsigned long long n; int main()
{
string str = "T.T^__^";
memset(a,,sizeof(a));
a[] = ;
a[] = ;
for(int i = ; i < ; i++)
a[i] = a[i - ] + a[i - ];
while(cin>>n)
{
while(n > )
{
int i = ;
while(a[i]<n)
i++;
n -= a[i-];
}
cout<<str[n-]<<endl;;
}
return ;
}

B - Big String的更多相关文章

  1. 透过WinDBG的视角看String

    摘要 : 最近在博客园里面看到有人在讨论 C# String的一些特性. 大部分情况下是从CODING的角度来讨论String. 本人觉得非常好奇, 在运行时态, String是如何与这些特性联系上的 ...

  2. JavaScript String对象

    本编主要介绍String 字符串对象. 目录 1. 介绍:阐述 String 对象的说明以及定义方式. 2. 实例属性:介绍 String 对象的实例属性: length. 3. 实例方法:介绍 St ...

  3. ElasticSearch 5学习(9)——映射和分析(string类型废弃)

    在ElasticSearch中,存入文档的内容类似于传统数据每个字段一样,都会有一个指定的属性,为了能够把日期字段处理成日期,把数字字段处理成数字,把字符串字段处理成字符串值,Elasticsearc ...

  4. [C#] string 与 String,大 S 与小 S 之间没有什么不可言说的秘密

    string 与 String,大 S 与小 S 之间没有什么不可言说的秘密 目录 小写 string 与大写 String 声明与初始化 string string 的不可变性 正则 string ...

  5. js报错: Uncaught RangeError: Invalid string length

    在ajax请求后得到的json数据,遍历的时候chrome控制台报这个错误:Uncaught RangeError: Invalid string length,在stackoverflow查找答案时 ...

  6. c# 字符串连接使用“+”和string.format格式化两种方式

    参考文章:http://www.liangshunet.com/ca/201303/218815742.htm 字符串之间的连接常用的两种是:“+”连接.string.format格式化连接.Stri ...

  7. 【手记】注意BinaryWriter写string的小坑——会在string前加上长度前缀length-prefixed

    之前以为BinaryWriter写string会严格按构造时指定的编码(不指定则是无BOM的UTF8)写入string的二进制,如下面的代码: //将字符串"a"写入流,再拿到流的 ...

  8. JavaScript中String对象的方法介绍

    1.字符方法 1.1 charAt() 方法,返回字符串中指定位置的字符. var question = "Do you like JavaScript?"; alert(ques ...

  9. 在多线程编程中lock(string){...}隐藏的机关

    常见误用场景:在订单支付环节中,为了防止用户不小心多次点击支付按钮而导致的订单重复支付问题,我们用 lock(订单号) 来保证对该订单的操作同时只允许一个线程执行. 这样的想法很好,至少比 lock( ...

  10. BCL中String.Join的实现

    在开发中,有时候会遇到需要把一个List对象中的某个字段用一个分隔符拼成一个字符串的情况.比如在SQL语句的in条件中,我们通常需要把List<int>这样的对象转换为“1,2,3”这样的 ...

随机推荐

  1. 百度云的ubuntu16.04.1部署Apache服务器+Django项目

    使用Apache和mod_wsgi部署Django 是一种久经考验的将Django投入生产的方法. mod_wsgi是一个Apache模块,可以托管任何Python WSGI应用程序,包括Django ...

  2. GET与POST传递数据的长度分析

    在客户机和服务器之间进行请求-响应时,两种最常被用到的方法是:GET 和 POST.GET - 从指定的资源请求数据,POST - 向指定的资源提交要被处理的数据.本篇文章我们就来分析一下GET与PO ...

  3. 基于稀疏表(Sparse Table)的RMQ(区间最值问题)

    在RMQ的其他实现方法中,有一种叫做ST的算法比较常见. [构建] dp[i][j]表示的是从i起连续的2j个数xi,xi+1,xi+2,...xi+2j-1( 区间为[i,i+2j-1] )的最值. ...

  4. Why Linux Doesn’t Need Defragmenting

    If you’re a Linux user, you’ve probably heard that you don’t need to defragment your Linux file syst ...

  5. com_pc-mcu

    #include <REG52.H> unsigned char UART_buff; bit New_rec = , Send_ed = , Money = ; void main (v ...

  6. 我的MVP呢?

    Ladies and gentelmen, welcome the MVP of NBA 16-2017 Season:... 呃,等下,好像哪里不对.那是因为,我要说的MVP根本就不是Most Va ...

  7. 服务器重复发送SYN ACK 和 TCP_DEFER_ACCEPT设置

    现象: 以下为其他网站提供,和我遇到的情况一样. 就是服务器老是重复发送 SYN, ACK. 4414.229553  client -> server TCP 62464 > http ...

  8. spring 学习 二 IOC/DI

    中文名称:控制反转 英文名称:( Inversion of Control ) 1 控制反转作用: 一般在编写java程序时,需要程序员自己创建对象的实例,例如 A a=new A();语句,就是程序 ...

  9. 一波水题 MZOJ 1035: 贝克汉姆

    #include <bits/stdc++.h> using namespace std; ; int n,m; int v[N],w[N],f[N]; int main() { scan ...

  10. yum安装nginx 加载image_filter 加载方式

    通过yum安装的nginx 加载image_filter方式方法: yum install -y gd-devel libgd gcc libgdyum install -y nginx-module ...