Wednesday, 9 September 2015

UVA 12195 Jingle Composing (UVALive 4481, Regionals 2009 >> Latin America)

///     Raihan Ruhin
///     CSE, Jahangirnagar University.
///     Dhaka-Bangladesh.
///     id: raihanruhin (topcoder / codeforces / codechef / uva / uvalive / spoj), 3235 (lightoj)
///     mail: raihanruhin@ (yahoo / gmail / facebook)
///     blog: ruhinraihan.blogspot.com

#include<bits/stdc++.h>
using namespace std;

#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define PI acos(-1.0)

#define MOD 1000000007
#define MX 100010


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int tc, kk=1, n;
    string s;
    char ch;
    while(cin>>s && s!="*")
    {
        int sl=s.size();
        for(int i=0;i<sl;i++)
            if(s[i]=='/')  s[i]=' ';
        stringstream os(s);
        int cnt=0;
        while(os>>s)
        {
            double sum=0.0;
            for(int i=0;i<s.size();i++)
                if(s[i]=='W') sum+=1;
                else if(s[i]=='H') sum+=1/2.0;
                else if(s[i]=='Q') sum+=1/4.0;
                else if(s[i]=='E') sum+=1/8.0;
                else if(s[i]=='S') sum+=1/16.0;
                else if(s[i]=='T') sum+=1/32.0;
                else if(s[i]=='X') sum+=1/64.0;
            //cout<<sum<<endl;
            if(sum+1e-2>=1.0 && sum-1e-2<=1.0)  cnt++;
        }
        cout<< cnt <<"\n";
    }
return 0;
}

No comments:

Post a Comment