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 如果最后一个数字和前一个合并。。f(n-2)
不合并 f(n-1)
fn = fn-2 + fn-1
大数!
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
#include<map>
#include<stack>
#include<fstream>
#include<set>
#include<memory>
#include<bitset>
#include<string>
#include<functional>
using namespace std;
typedef long long LL;
const int MAXN = 1e6 + ;
#define INF 0x3f3f3f3f
#define MAXN 203 int a[MAXN][MAXN];
char str[MAXN];
void add(int to[], int add[])
{
if (to[] < add[])
to[] = add[];
for (int i = ; i <= to[]; i++)
to[i] += add[i];
for (int i = ; i <= to[]; i++)
{
to[i + ] += to[i] / ;
to[i] %= ;
}
if (to[to[] + ] > )
to[]++;
}
void Init()
{
memset(a, , sizeof());
a[][] = , a[][] = ;
a[][] = , a[][] = ;
for (int i = ; i < MAXN; i++)
{
add(a[i], a[i - ]);
add(a[i], a[i - ]);
}
}
void print(int p)
{
for (int i = a[p][]; i > ; i--)
printf("%d", a[p][i]);
printf("\n");
}
int main()
{
int n, t;
scanf("%d", &n);
Init();
while (n--)
{
scanf("%s", &str);
t = strlen(str);
print(t);
}
}

1sting 大数 递推的更多相关文章

  1. HDU-1041-Computer Transformation,大数递推,水过~~

                                                                                  Computer Transformatio ...

  2. POJ 1737 Connected Graph (大数+递推)

    题目链接: http://poj.org/problem?id=1737 题意: 求 \(n\) 个点的无向简单(无重边无自环)连通图的个数.\((n<=50)\) 题解: 这题你甚至能OEIS ...

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

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

  4. UVa 10328 Coin Toss(Java大数+递推)

    https://vjudge.net/problem/UVA-10328 题意: 有H和T两个字符,现在要排成n位的字符串,求至少有k个字符连续的方案数. 思路:这道题目和ZOJ3747是差不多的,具 ...

  5. CodeVs 3150 (大数 + 递推)

    #include<iostream> #include<cstdio> #include<cstring> #include<string> #incl ...

  6. hdu 1133 Buy the Ticket (大数+递推)

    Buy the Ticket Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

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

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

  8. Tiling(递推+大数)

    Description In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a sample tili ...

  9. Children’s Queue HDU 1297 递推+大数

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1297 题目大意: 有n个同学, 站成一排, 要求 女生最少是两个站在一起, 问有多少种排列方式. 题 ...

随机推荐

  1. Tomcat源码分析----eclipse中搭建源码环境

    前提:JDK,至少1.7,ant,要设置ANT_HOME环境变量,需要再classpath中增加ant的lib目录,在path变量中增加ant的bin目录 1.官网下载tomcat源码包:apache ...

  2. TCP/IP 协议、地址

    (一)TCP/IP 协议是端与端之间通信的基础,计算机网络,分组报文,协议是将信息正确传递的组成. 计算机网络: 由多个客户端,中间路由组成的网络体系,每个节点都一个ip进行唯一识别.路由是作为一个转 ...

  3. 拼图游戏源码-swift版项目源码

    作者fanyinan,源码PuzzleProject,公司的项目中需要一个拼图游戏,之前有手动拼图和随机打乱的功能,近期又由于个(xian)人(zhe)爱(dan)好(teng)自己加入了自动拼图功能 ...

  4. 计算器Pro应用项目源码

    本计算器实现了一些简单的功能,可能本身还存在一些缺陷,希望大家提建议,能够改进一下. 源码项目我已经上传到源码天堂那里了:http://code.662p.com/list/11_1.html < ...

  5. 针对windowsserver 创建iis站点访问出错的解决方案(HTTP 错误 500.19 - Internal Server Error)

    错误如下:   服务器错误 Internet信息服务 7.0 错误摘要HTTP 错误 500.19 - Internal Server Error 无法访问请求的页面,因为该页的相关配置数据无效. 详 ...

  6. WOJ600——水题

    第一次做本校OJ的题,被坑的好惨啊! 题目:600.Minimum  Distance 题目大意:给定平面上3个点A.B.C,求平面上的任一顶点P,使得|PA|+2|PB|+3|PC|. 由于刚好在这 ...

  7. cesium 原理 之 command拼接

    VAO VAO(Vertext Array Object),中文是顶点数组对象.之前在<Buffer>一文中,我们介绍了Cesium如何创建VBO的过程,而VAO可以简单的认为是基于VBO ...

  8. CAD交互绘制带颜色宽度的直线(com接口)

    用户可以在控件视区任意位置绘制直线. 主要用到函数说明: _DMxDrawX::DrawLine 绘制一个直线.详细说明如下: 参数 说明 DOUBLE dX1 直线的开始点x坐标 DOUBLE dY ...

  9. vue的[__ob__: Observer]

    为什么会获取不到里面的值 因为:vue data 里面值都是有这个属性的.这是被vue接管的数据,observer是Vue核心中最重要的一个模块(个人认为),能够实现视图与数据的响应式更新,底层全凭o ...

  10. Spring Boot 打包分离依赖 JAR 和配置文件

    <properties> <java.version>1.8</java.version> <project.build.sourceEncoding> ...