#include< iostream>
#include< stdio.h>
#include< string.h>
using namespace std;
int main()
{
int l,i,count=0,t,j;
char word[101];
scanf("%d\n",&t);
if(t<=40)
{
for(j=0;j<t;j++)
{
count=0;
gets(word);
l=strlen(word);
for(i=0;i<l;i++)
{
if(word[i]=='A'||word[i]=='D'||word[i]=='O'||word[i]=='P'||word[i]=='R')
count++;
else if(word[i]=='B')
{
count++;
count++;
}
}
printf("%d\n",count);
}
}
return 0;
}
1 Like
You don’t need to put that condition if(t<=40)
,that’s given in the problem to tell you which data type to use,suppose if it were 10^9,then you would have used long long int. So,just remove that if condition and then try it out.
-1: that condition is not wrong, is redundant, but it is not a problem, also 10 fits nicely in int
1 Like
You missed one letter, try the alphabet again
As @rishabhprsd7 said, you missed ‘Q’, so ran to WA.
Here is my solution, which is copy from you and added condition “if word[i] = ‘Q’ then count++”
http://www.codechef.com/viewsolution/5462914
Oops!,Thanks now i got that…