Hangzhou Electric 1865--1sting

Source: Internet
Author: User

1sting

Time limit:5000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 4133 Accepted Submission (s): 1547


Problem Descriptionyou would be given a string which only contains ' 1 '; You can merge both 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 was to find the total number of result can get.

Inputthe first line was a number n refers to the number of test cases. Then n lines follows, each line has a string of made up of ' 1 '. The maximum length of the sequence is 200.

Outputthe output contain n lines, each line output the number of the result can get.

Sample INPUT3 1 11 11111

Sample OUTPUT1 2 8

Authorz.jt

Source2008 Hangzhou Electric Training Team Tryouts--warm-up

Recommendlcy | We have carefully selected several similar problems for you:1715 1250 1133 2100 1753//idea: recursive; only 1 and 2 of these two digits are present in the number →→→f (n ) = f (n-1) + f (n-1);
1#include <stdio.h>2#include <string.h>3 intfei[ -][1001];4 intMain ()5 {6     intN;7     Charstr[ -];8     intI, J;9     intTemp, plus =0;Tenmemset (Fei,0,sizeof(FEI)); Onefei[1][0] =1; Afei[2][0] =2;  -      for(i=3; i<201; i++)   -     { the          for(j=0; j<1001; J + +)///two-D array subscript indicates the number of digits; -         { -temp = fei[i-1][J] + fei[i-2][J] +Plus; -FEI[I][J] = temp%Ten; +Plus = temp/Ten; -         } +     } Ascanf"%d", &n); at      while(n--) -     { -scanf"%s", str); -         intLen =strlen (str); -          for(i= +; i>=0; i--) -         if(Fei[len][i]) in          Break; -          for(; i>=0; i--) toprintf"%d", Fei[len][i]); +printf"\ n"); -     } the     return 0; *}

Hangzhou Electric 1865--1sting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.