Monday, January 18, 2016

UVa 11541 - Decoding

// UVa 11541 - Decoding

#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
	int tt;
	cin >> tt;
	for (int t = 1; t <= tt; t++) {
		string l;
		cin >> l;
		int m = 0;
		char ch = l[0];
		string sol = "";
		for (int i = 0; i < l.length(); i++) {
			if (l[i] >= '0' && l[i] <= '9')
				m = m * 10 + (l[i] - '0');
			else {
				for (int j = 0; j < m; j++)
					sol = sol + ch;
				ch = l[i];
				m = 0;
			}
		}
		for (int j = 0; j < m; j++)
			sol = sol + ch;
		printf("Case %d: ", t);
		cout << sol << endl;
	}
	return 0;
}

No comments:

Post a Comment