Little Sheep and a paper
Time Limit : 2 Second
Memory Limit : 128 MB
Submission: 479
Solved: 140
- Description
- One day, god Sheep gets an AK(all kill) in a contest, so he is very boring, then he just plays with a paper. The paper has two faces called A and B. Sheep finds the paper can be folded for infinity times, and now Sheep thinks the paper is interesting, so he tries to fold the paper in half for many times. He finds out he has four way to make the paper folded in half, there are listed below:
图片请见 PDF版题目。
At first, god Sheep keeps the face A of the paper faced to him,and he fold the paper for many times. In the end, Sheep opens up the paper, and keeps the face A faced to him again. Now the question is : How many creases on the face A of the paper are protruding? God sheep solves the question without 2 seconds. Can you? You should make your anwser mod 100000009.
- Input
- The first line of input contains a single positive integer N , which means the number of test cases. The following N lines gives N non-empty strings containing only characters in "UDLR", which is the sequences of the actions of the Sheep to fold paper. The length of the each string is a positive number less than 10^6.
- Output
- For each case output the anwser mod 100000009 in a line.
- sample input
-
4 L LR DLUR ULULL
- sample output
-
0 1 10 22
- hint
- source
- The 7th(2012) ACM Programming Contest of HUST Problem Setter: Shuo Hu