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. IE8下ajax兼容问题

    function crossDomainAjax(url, successCallback) { // IE8 & 9 only Cross domain JSON GET request i ...

  2. 工具类学习-java实现邮件发送激活码

    问题:用java实现服务器发送激活码到用户邮件. 步骤一:如果是个人的话,确保在本地安装邮件服务器(易邮服务器)和邮件客户端(foxmail). 步骤二:导入jar包  mail.jar,其他的需要什 ...

  3. css的过渡背景色

    css3新增的渐变背景色属性用法 原博客地址:http://caibaojian.com/css3-background-gradient.html

  4. 微信小程序组件解读和分析:十一、label标签

    label标签组件说明: label标签,与html的label标签基本一样.label 元素不会向用户呈现任何特殊效果.不过,它为鼠标用户改进了可用性.如果您在 label 元素内点击文本,就会触发 ...

  5. 输入域名网站访问不了,ping与ftp都正常,这情况有可能域名被墙

    被墙的风险 1.首先域名没有备案,而且服务器是国外的服务器, 2.域名解析到国外服务器 总结:以上两点有很大几率被墙的风险 被墙的解决方案: 1.换新域名并备案(不换新域名走第二步,域名一定要备案) ...

  6. 迅为嵌入式4418/6818开发板QT-HDMI显示

    本文转自迅为论坛:http://www.topeetboard.com 平台:迅为4418/6818开发平台 1.首先请确认下光盘资料的日期(只有20171120及以后更新的光盘支持QT HDMI显示 ...

  7. HP11.31安装11.2.0.3实施手册

    1 前言 此文档详细描述了Oracle 11gR2 数据库在HP11.31上的安装RAC的检查及安装步骤.文档中#表示root用户执行,$表示grid或oracle用户执行. 2 系统环境 操作系统环 ...

  8. Which dispatch method would be used in Swift?-Existential Container

    In this example: protocol MyProtocol { func testFuncA() } extension MyProtocol { func testFuncA() { ...

  9. Discuz!代码

    我如何使用Discuz!代码   Discuz!代码 效果 [b]粗体文字 Abc[/b] 粗体文字 Abc [i]斜体文字 Abc[/i] 斜体文字 Abc [u]下划线文字 Abc[/u] 下划线 ...

  10. php 阿里云短信验证码

    阿里云短信服务:https://dysms.console.aliyun.com 1.准备 1.1.创建签名.模板 1.2.创建.使用阿里云秘钥 地址:https://usercenter.conso ...