HDUJ 1865 1sting

1sting

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 3227    Accepted Submission(s): 1237

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
8
import java.util.Scanner;
import java.math.BigInteger;

public class yugtg {  

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        BigInteger s[] = new BigInteger[205];
        s[1] = new BigInteger("1");
        s[2] = new BigInteger("2");
        for(int i=3;i<=200;i++)
        	s[i] = s[i-1].add(s[i-2]);

        int n = cin.nextInt();
        for(int i=0;i<n;i++)
        {
        	String S = cin.next();
        	int l = S.length();

        	System.out.println(s[l]);
        }
    }
}

HDUJ 1865 1sting

时间: 2024-10-20 12:44:36

HDUJ 1865 1sting的相关文章

HDU 1865 1sting (递推、大数)

1sting Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7573    Accepted Submission(s): 2945 Problem Description You will be given a string which only contains ‘1’; You can merge two adjacent ‘1’

hdu 1865 1sting

高精度 斐波那契数 #include<iostream> #include<cstring> #include<algorithm> using namespace std; const int L=110; string add(string a,string b)//只限两个非负整数相加 { string ans; int na[L]={0},nb[L]={0}; int la=a.size(),lb=b.size(); for(int i=0;i<la;i+

HDUJ 1242 Rescue 搜索

Rescue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 15582    Accepted Submission(s): 5656 Problem Description Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is

HDUJ 1392 Surround the Trees 凸包

Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7203    Accepted Submission(s): 2752 Problem Description There are a lot of trees in an area. A peasant wants to buy a rope to

HDUJ 1151 Air Raid 最大匹配

Air Raid Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3035    Accepted Submission(s): 1972 Problem Description Consider a town where all the streets are one-way and each street leads from on

HDUJ 2952 Counting Sheep 搜索

Counting Sheep Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2039    Accepted Submission(s): 1342 Problem Description A while ago I had trouble sleeping. I used to lie awake, staring at the c

HDU 1865

1sting Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3200    Accepted Submission(s): 1230 Problem Description You will be given a string which only contains ‘1’; You can merge two adjacent ‘1’

HDUJ 1754 I Hate It

I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 37856    Accepted Submission(s): 14981 Problem Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少. 这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老师

HDUJ 1316 How Many Fibs?

How Many Fibs? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4106    Accepted Submission(s): 1623 Problem Description Recall the definition of the Fibonacci numbers: f1 := 1 f2 := 2 fn := fn-