Monday, August 29, 2016

UVa 12195 - Jingle Composing

// UVa 12195 - Jingle Composing

#include <iostream>
#include <string>
#include <map>
using namespace std;

int main() {
	map<char, int> val;
	val['W'] = 64;
	val['H'] = 32;
	val['Q'] = 16;
	val['E'] = 8;
	val['S'] = 4;
	val['T'] = 2;
	val['X'] = 1;
	string l;
	while (getline(cin, l) && (l.length() != 1 || l[0] != '*')) {
		int now = 0, sol = 0;
		for (int i = 1; i < l.length(); i++) {
			if (l[i] == '/') {
				if (now == 64)
					sol++;
				now = 0;
			} else
				now += val[l[i]];
		}
		cout << sol << endl;
	}
	return 0;
}

No comments:

Post a Comment