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