1sting hd 1865
Problem 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
3
1
11
11111
Sample Output
1
2
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
3
1
11
11111
Sample Output
1
2
8
#include <stdio.h>
#include <string.h>
int str1[210][300]={{0}};
int main()
{
int n;
scanf("%d",&n);
getchar();
while(n--)
{
char str[300];
gets(str);
int len=strlen(str);
str1[0][0]=1;
str1[1][0]=2;
for(int i=2;i<len;i++)
{
int c=0,k;
for(k=0;k<300;k++)
{
int s=str1[i-1][k]+str1[i-2][k]+c;
str1[i][k]=s%10;
c=s/10;
}
while(c)
{
str1[i][k++]=c%10;
c/=10;
}
}
int i;
for(i=299;i>=0;i--)
if(str1[len-1][i])
break;
for(int j=i;j>=0;j--)
printf("%d",str1[len-1][j]);
printf("\n");
}
return 0;
}
相關文章
- P1865 A % B Problem
- Picture hd 2052
- 密碼 hd 2043密碼
- Big Number hd 1212
- the Sum of Cube hd 5053
- 不要62 hd 2089
- 統計母音 hd 2027
- 字串統計 hd 2017字串
- 偶數求和 hd 2015
- 剪花布條hd 2087
- A + B Problem II hd 1002
- 母牛的故事 hd 2018
- 18歲生日 hd 1201
- 美素數 hd 4548
- 素數判定 hd 2012
- 又見GCD hd 2504GC
- HD Tune軟體怎麼用?使用HD tune檢測硬碟的方法教程硬碟
- Lowest Common Multiple Plus hd 2028
- 海選女主角 hd 2022
- 多項式求和 hd 2011
- 求平均成績 hd 2023
- 折線分割平面 hd 2050
- 無限的路 hd 2073
- 整除的尾數 hd 2099
- 大菲波數 hd 1715
- 超級樓梯 hd 2041
- 最小公倍數 hd 1108
- 查詢最大元素 hd 2025
- 一隻小蜜蜂 hd 2044
- 分拆素數和 hd 2098
- win10如何使用hd tune pro工具_win10使用hd tune pro工具的教程Win10
- 首字母變大寫 hd 2026
- 不容易系列之二 hd 2042
- win10系統hd color模式有什麼用_win10系統hd color模式使用教程Win10模式
- 資料的交換輸出 hd 2016
- 簡易版之最短距離 hd 2083
- win10 64位沒有realtek hd audio怎麼找回_win10找不到realtek hd audio如何解決Win10
- C語言合法識別符號 hd 2024C語言符號