Monday, July 18, 2016

UVA 1585 Solution

Unknown
#include<cstdio>
#include<cstring>
using namespace std;

int main()
{
 int tc,score,a[90];
 char s[90];
 scanf("%d",&tc);
 getchar();
 while (tc--)
 {
  scanf("%s",s);
  int l=strlen(s);
  if (s[0]=='O')a[0]=1;
  else a[0]=0;
  score=a[0];
  for (int i=1;i<l;i++)
  {
   if (s[i]=='O')a[i]=a[i-1]+1;
   else a[i]=0;
   score+=a[i];
  }
  printf("%d\n",score);
 }
 return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,