This is my code for SETNJA SPOJ in C (spoj.pl/problems/SETNJA/)
I am getting WA. Can someone provide good test case for this? Does the answer limit exceeds from unsigned long long?
#include<stdio.h>
typedef unsigned long long ULLD;
ULLD ans=0ull;
char str[10001];
int length;
void recurse(int i, ULLD temp)
{
if(str[i]=='\0')
{
ans=ans+temp;
return;
}
if(str[i]=='L') recurse(i+1,2*temp);
else if(str[i]=='R') recurse(i+1,2*temp+1);
else if(str[i]=='P') recurse(i+1,temp);
else if(str[i]=='*')
{
recurse(i+1, 2*temp);
recurse(i+1 , 2*temp +1);
recurse(i+1, temp);
}
}
int main()
{
scanf("%s",str);
length=strlen(str);
recurse(0,1);
printf("%llu",ans);
return 0;
}