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. Docker安装MySQL忽略大小写问题的问题

    原文:Docker安装MySQL忽略大小写问题的问题 连接MySQL: 查看当前mysql的大小写敏感配置show global variables like '%lower_case%';+---- ...

  2. 【BZOJ 1260】[CQOI2007]涂色paint

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 区间DP 设f[i][j]表示i..j这个区间变成目标需要的最少染色次数. f[i][i] = 1 然后考虑f[i][j]的产生方法 ...

  3. Building a Space Station POJ 2031 【最小生成树 prim】

    http://poj.org/problem?id=2031 Description You are a member of the space station engineering team, a ...

  4. Linux路由表的抽象扩展应用于nf_conntrack

    思想 标准IP路由查找的过程为我们提供了一个极好的"匹配-动作"的例程. 即匹配到一个路由项.然后将数据包发给该路由项指示的下一跳.假设我们把上面对IP路由查找的过程向上抽象一个层 ...

  5. 重写MPAndroidChart显示标记

    MPAndroidChart是实现图表功能的优秀控件, 能够完毕大多数绘制需求. 对于改动第三方库而言, 优秀的架构是继承开发, 而不是把源代码拆分出去. MP在显示标记控件(MarkView)时, ...

  6. Android Camera+SurfaceView实现自己定义拍照

    对Activity强制横屏,保证预览方向正确. 使用OrientationEventListener监听设备方向.推断竖拍时,旋转照片后再保存.保证竖拍时预览图片和保存后的图片方向一致. 执行效果: ...

  7. 什么是MySQL?(一)

    课程大纲 第一章:初识MySQL 1.1什么是MySQL?  1.2如何安装MySQL?  1.3如何配置MySQL?  1.4如何启动和关闭MySQL?  1.5MySQL的登录和退出  1.6如何 ...

  8. python 3.x 学习笔记4(函数)

    1.编程方式分:面向对象.面向过程.函数式编程 2.区分面向对象---->类---->class面向过程---->过程---->def函数式编程---->函数----&g ...

  9. Android属性动画-Interpolator和ViewPropertyAnimator的用法

    Interpolator的用法 Interpolator这个东西很难进行翻译,直译过来的话是补间器的意思,它的主要作用是可以控制动画的变化速率,比如去实现一种非线性运动的动画效果.那么什么叫做非线性运 ...

  10. Android——PullToRefresh自动刷新

    需求:强制刷新 方法一: PullToRefreshListView本身提供了一个setRefreshing()接口,调用该接口会自动触发下拉刷新的操作(前提是支持下拉刷新).按照一般的操作我们直接在 ...