/
CHEFLR.c
45 lines (43 loc) · 970 Bytes
/
CHEFLR.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<stdio.h>
int main()
{
int temp;
int i;
char child;
unsigned long int result;
scanf("%d\n",&temp);
while(temp--){
result=1;
i=0;
child=getchar();
while(child!='\n' && child!=EOF)
{
if(i==0)
{
if (child=='l')
result=result*2;
if (child=='r')
result=result*2+2;
i=1;
}
else
{
if (child=='l')
result=result*2-1;
if (child=='r')
result=result*2+1;
i=0;
}
if (result>1000000007)
{
result=result%1000000007;
}
child=getchar();
}
if (result==1000000007)
printf("0" );
else
printf("%ld\n",result );
}
return 0;
}