题目链接:http://acm.hust.edu.cn/vjudge/contest/121397#problem/F

http://acm.hdu.edu.cn/showproblem.php?pid=1865

Description

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. 

Input

The 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. 

Output

The output contain n lines, each line output the number of result you can get . 
 
Sample Input

Sample Output

AC代码:

 #include <stdio.h>
#include <string.h>
#define maxn 300
int str1[maxn][maxn];
int main()
{
int T, i, j;
scanf("%d ",&T); while(T--)
{
char str[];
gets(str); int len=strlen(str);
str1[][]=;
str1[][]=; for(i=;i<len;i++)
{
int c=,k;
for(k=;k<maxn;k++)
{
int s=str1[i-][k]+str1[i-][k]+c;
str1[i][k]=s%;
c=s/;
}
while(c)
{
str1[i][k++]=c%;
c/=;
}
} for(i=;i>=;i--)
if(str1[len-][i])
break; for(j=i;j>=;j--)
printf("%d",str1[len-][j]);
printf("\n");
}
return ;
}

A完还A:

 #include<stdio.h>
#include<string.h> #define N 210
int f[][N]; void init()
{
int i, j;
f[][] = ;
f[][] = ; for(i = ; i <= ; i++)
for(j = ; j <= ; j++)
{
f[i][j] += f[i-][j] + f[i-][j];
if(f[i][j] >= )
{
f[i][j] -= ;
f[i][j+]++;
}
}
} int main()
{ int i, j, t;
char s[N]; scanf("%d", &t);
init(); while(t--)
{
scanf("%s", s); int n = strlen(s); int k = ;
for (; f[n][k] == ; k--);
for (; k >= ; k--)
printf ("%d",f[n][k]); printf("\n"); } return ;
}

HDU - 1865 1string(大数)的更多相关文章

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

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

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

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

  3. HDU 5047 Sawtooth(大数模拟)上海赛区网赛1006

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5047 解题报告:问一个“M”型可以把一个矩形的平面最多分割成多少块. 输入是有n个“M",现 ...

  4. HDU 1715 (大数相加,斐波拉契数列)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1715 大菲波数 Time Limit: 1000/1000 MS (Java/Others)     ...

  5. hdu 5718(Oracle)大数加法

    曾经有一位国王,统治着一片未名之地.他膝下有三个女儿. 三个女儿中最年轻漂亮的当属Psyche.她的父亲不确定她未来的命运,于是他来到Delphi神庙求神谕. 神谕可以看作一个不含前导零的正整数n n ...

  6. hdu 5351 规律+大数

    题目大意:定义了一种fib字符串,问第n个fib串的前m个字母前后相等串的最大长度,大约就是这样的 其实主要读完题意的时候并没有思路,但是列几个fib字符串就会发现,除了fib1以外,所有串的前面都是 ...

  7. hdu 1063 Exponentiation 大数

    Problem Description Problems involving the computation of exact values of very large magnitude and p ...

  8. hdu 1002 Java 大数 加法

    http://acm.hdu.edu.cn/showproblem.php?pid=1002 PE   由于最后一个CASE不须要输出空行 import java.math.BigInteger; i ...

  9. HDU 1402 FFT 大数乘法

    $A * B$ FFT模板题,找到了一个看起来很清爽的模板 /** @Date : 2017-09-19 22:12:08 * @FileName: HDU 1402 FFT 大整数乘法.cpp * ...

随机推荐

  1. PIVOT就是行转列,UNPIVOT就是列传行

    PIVOT通过将表达式某一列中的唯一值转换为输出中的多个列来旋转表值表达式,并在必要时对最终输出中所需的任何其余列值执行聚合.UNPIVOT与PIVOT执行相反的操作,将表值表达式的列转换为列值. 通 ...

  2. 笨方法学python--提示别人

    1 上次学到使用raw_input(), 还可以如下使用: age = raw_input("age?") 2 命令名查看raw_input的说明 unit, pydoc raw_ ...

  3. DHCP 协议的 8 种消息类型及功能服务器

    1) 主机发送 DHCP Discover 广播包在网络上寻找 DHCP 服务器: 单播数据包, 地址. 2) DHCP 服务器向主机发送 DHCP Offer 单播数据包,包含 IP 地址.MAC ...

  4. Minigui开发之遥控控制逻辑算法

    引言 在开发公司的minigui产品时,需要用遥控器来切换显示屏上的图标和控件,这就涉及到一个问题,如何获得下一个选中的图标或控件呢? 解决思路 利用每个控件自身的ID号,建立一张类似矩阵的表,用坐标 ...

  5. Struts2--课程笔记2

    动态方法调用(在请求的时候,再明确具体的响应方法,配置的时候不明确): LoginAction类中有两个方法some和second 1. 动态方法的调用(修改常量struts.enable.Dynam ...

  6. javaWEB总结(7):HttpServlet和HttpServletRequest

    前言:HttpServletRequest对象封装了客户端进行HTTP协议请求时的所有信息,HttpServletRequest继承了ServletRequest,所以和ServletRequest一 ...

  7. android配置文件详解

    <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="ht ...

  8. UVA 10480 Sabotage

    最小割+输出方案 #include<cstdio> #include<cstring> #include<string> #include<cmath> ...

  9. python字符串中的中文处理

    python字符串中的字符串默认并非是unicode,如果在字符创中使用Unicode字符,如中文字符,必须要经过转换, 方式1: text = u"中文" 方式2: text = ...

  10. thinkphp的目录结构设计经验总结1

    ---恢复内容开始--- 用thinkphp开发了好些项目了:最近准备抽空写一些经验总结: 希望能给刚开始接触tp的童鞋们提供一些开发的方案:少走一些弯路:少踩一些坑: 这些绝对都是些精华干货:耐着性 ...