You will be given a string which only contains ‘1’; You can merge two adjacent ‘1’ to be ‘2’, or leave the ‘1’ there. Surly, you may get many different results. For example, given 1111 , you can get 1111, 121, 112,211,22. Now, your work is to find the total number of result you can get.
InputThe first line is a number n refers to the number of test cases. Then n lines follows, each line has a string made up of ‘1’ . The maximum length of the sequence is 200.
      OutputThe output contain n lines, each line output the number of result you can get .
Sample Input

3
1
11
11111

Sample Output

1
2
8
自己找规律可得为Fibonacci数列,但递归到已为大位数运算,long long __int64皆不可以,最好的办法为开数组
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn=;
int a[][maxn];
int main()
{
int n,i,j,count,T;
for(i=;i<=;i++)
{
for(j=;j<=;j++)
{
a[i][j]=;
}
}
a[][]=;
a[][]=;
for(i=;i<=;i++)
{
for(j=;j<=;j++)
{
a[i][j]=a[i][j]+a[i-][j]+a[i-][j];
if(a[i][j]>=)
{
a[i][j]=a[i][j]-;
a[i][j+]=a[i][j+]+;
}
}
}
cin>>T;
while(T--)
{
char b[];
cin>>b;
n=strlen(b);
for(i=;i>=;i--)
{
if(a[n][i]!=)
{
count=i;
break;
}
}
for(i=count;i>=;i--)
{
cout<<a[n][i];
}
cout<<endl;
}
return ;
}

1sting的更多相关文章

  1. hdu1865 1sting (递归+大数加法)

    1sting Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Subm ...

  2. HDU 1865 1sting (递推、大数)

    1sting Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Subm ...

  3. HDOJ/HDU 1865 1sting(斐波拉契+大数~)

    Problem Description You will be given a string which only contains '1'; You can merge two adjacent ' ...

  4. D - 1sting(相当于斐波那契数列,用大数写)

    Description You will be given a string which only contains ‘1’; You can merge two adjacent ‘1’ to be ...

  5. 【hdoj_1865】1sting(递推+大数)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1865 本题的关键是找递推关系式,由题目,可知前几个序列的结果,序列长度为n=1,2,3,4,5的结果分别是 ...

  6. 1sting 大数 递推

    You will be given a string which only contains ‘1’; You can merge two adjacent ‘1’ to be ‘2’, or lea ...

  7. HDUOJ--1865 1string

    1sting Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Subm ...

  8. Redis之Redis的数据类型

    ​1.Redis的数据类型     Redis支持五种数据类型:string(字符串),hash(哈希),list(列表),set(无序集合)及ZSet(有序集合)  2.String(字符串)    ...

随机推荐

  1. Mock+Proxy在SDK项目的自己主动化測试实战

    项目背景 广告SDK项目是为应用程序APP开发者提供移动广告平台接入的API程序集合,其形态就是一个植入宿主APP的jar包.提供的功能主要有以下几点: - 为APP请求广告内容 - 用户行为打点 - ...

  2. 在swt中获取jar包中的文件 uri is not hierarchical

    uri is not hierarchical 学习了:http://blog.csdn.net/zdsdiablo/article/details/1519719 在swt中获取jar包中的文件: ...

  3. Android中设置半个屏幕大小且居中的button布局 (layout_weight属性)

            先看例如以下布局 : 

  4. ssh跳板登陆太麻烦,使用expect每次自动登录 利用expect 模拟键盘动作,在闲置时间之内模拟地给个键盘响应

    #!/usr/bin/expect -f #设置超时时间 set timeout #这里设置了跳板机的密码 set password "你的跳板机密码" #连接跳板机 spawn ...

  5. python 3.x 写 shell sed 替换功能

    shell sed 替换功能 f1 = open('yesterday','r',encoding='utf-8') f2 = open('yesterday2','w',encoding='utf- ...

  6. svn回到某个历史版本的做法

    作者:朱金灿 来源:http://blog.csdn.net/clever101 一.在选中的文件上弹出svn的右键菜单,单击"Updateto revision"菜单项,如下图: ...

  7. 从C到OCblocks语法的声明

           在过去的一段时间,我开始从C的一些简单声明到更复杂的学习直到我开始学习了Objective-C中的blocks.我花了很长的一段时间去理解他并且认识到一旦你理解它是怎样组织的并且是怎样产 ...

  8. 《剑指offer》字符串中的字符替换

    一.题目描述 请实现一个函数,将一个字符串中的空格替换成"%20".例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy. 二.输入描 ...

  9. 函数响应式编程(FRP)从入门到”放弃”——基础概念篇

    前言 研究ReactiveCocoa一段时间了,是时候总结一下学到的一些知识了. 一.函数响应式编程 说道函数响应式编程,就不得不提到函数式编程,它们俩到底有什么关系呢?今天我们就详细的解析一下他们的 ...

  10. P3066 [USACO12DEC]逃跑的BarnRunning Away From… 树上差分_树上倍增

    code: #include <cstdio> using namespace std; #define ll long long const int N=200005; int n,fa ...