题目链接: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. iOS应用性能调优的4个建议和技巧

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

  2. MFC下MCI的使用播放音乐

    最近研究了一下MFC下的音乐的播放,主要使用了MCI 1.需要包含的库文件 在链接资源里(link)添加库文件VFW32.lib winmm.lib 2.包含的头文件 #include <mms ...

  3. lucene 简单搜索步骤

    1.创建IndexReader实例: Directory dir = FSDirectory.open(new File(indexDir)); IndexReader reader = Direct ...

  4. 将dom4j格式化为标准的xml字符串

    StringWriter writer = new StringWriter(); OutputFormat format = OutputFormat.createPrettyPrint(); fo ...

  5. Ubuntu cron定时执行任务

    1.添加自定义事件 crontab -e 2.选定编辑器 3.添加执行代码 * * * * /usr/bin/curl http://www.exmple.com/cron.php crontab 命 ...

  6. HDU 5769 Substring

    后缀数组. 然后按照排序完成之后的顺序,每个后缀统计贡献量. 统计第i个后缀的贡献的时候,如果这个后缀中没有X,贡献度为0. 有贡献的分3种情况考虑: 1.如果这个后缀height部分等于0(即与前一 ...

  7. Windows API 之 FormatMessage

    FormatMessage Formats a message string. The function requires a message definition as input. The mes ...

  8. OpenCV成长之路:图像滤波

    http://ronny.blog.51cto.com/8801997/1394138 OpenCV成长之路:图像滤波 2014-04-11 14:28:44 标签:opencv 边缘检测 sobel ...

  9. 矩阵快速幂AC代码HDU 2035

    #include <iostream> using namespace std;const int MOD = 1000;//像这样的一个常量就应该专门定义一下 int PowMod(in ...

  10. 解决ORA-00904: invalid identifier标识符无效

    方法/步骤 1 大部分情况下,此错误是由于引用了不存在的列名导致的.比如select name from Studtent 当studeng表中无name列时,系统就会报此错误. 2 解决思路是,确定 ...