题目链接: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. spring容器启动的加载过程(一)

    使用spring,我们在web.xml都会配置ContextLoaderListener <listener> <listener-class> org.springframe ...

  2. iOS应用性能调优的4个建议和技巧

    任何一个能在用户手机屏幕中占有一席之地的iOS app都包含3个关键因素:想法好.设计出色.性能卓越.本文将分享一些iOS应用性能调优的4个建议和技巧. Tip #1:把图片资源压缩到最小.    i ...

  3. 接入支付宝出现交易订单处理失败,请稍后再试(ALI64)的错误【转】

    接入第三方平台的时候,有时虽然按照文档来做,但是总是还会有各种各样的问题. 上次在接入支付宝的时候就碰到了交易订单处理失败,请稍后再试(ALI64)这样的错误,后来经过排查和总结,一般来讲这种问题都是 ...

  4. 第四十二节,configparser特定格式的ini配置文件模块

    configparser用于处理特定格式的文件,其本质上是利用open来操作文件. 特定格式的ini配置文件模块,用于处理ini配置文件,注意:这个ini配置文件,只是ini文件名称的文本文件,不是后 ...

  5. 文本输入框和下拉菜单特效-用正则表达式验证E-mail格式

    ———————————————————————————— <script type="text/javascript">                         ...

  6. JavaScript高级程序设计:第十一章

    一.选择符API SelectorsAPILevel 1的核心是两个方法:querySelector()和querySelectorAll(). 1. querySelector()方法 queryS ...

  7. hud 2099

    #include <stdio.h> #include <stdlib.h> int main() { int m,n,i,flag; ) { flag=; && ...

  8. nefu 196 让气球飞吧

    description 国际大学生程序设计竞赛已经发展成为最具影响力的大学生计算机竞赛,ACM-ICPC以团队的形式代表各学校参赛,每队由3名队员组成,一个队每做出来一个题该队就会获得该题对应颜色的气 ...

  9. oracle添加sequence

    CREATE SEQUENCE seq_tm_function INCREMENT BY 1 -- 每次加几个 START WITH 100000015 -- 从1开始计数 NOMAXVALUE -- ...

  10. 这一招让 Word 帮你自动生成文件目录,也能自动更新

    学生的研究报告或是公司员工的提案企划书,为了务求严明详尽,往往是洋洋洒洒数十页或甚至上百页之多,像这样大篇幅的文件,在结构上通常会划分为好几个部分,比如像论文就会区分为封面.摘要.内文章节.参考文献等 ...