Tuesday, August 18, 2015

UVa 10550 - Combination Lock

// UVa 10550 - Combination Lock

#include <iostream>
using namespace std;

int main() {
	int ini, fst, snd, thr;
	cin >> ini >> fst >> snd >> thr;
	while (ini || fst || snd || thr) {
		int sol = 360 * 2;
		if (ini > fst)
			sol += (ini - fst) * 9;
		else
			sol += (ini + 40 - fst) * 9;
		sol += 360;
		if (snd > fst)
			sol += (snd - fst) * 9;
		else
			sol += (snd + 40 - fst) * 9;
		if (snd > thr)
			sol += (snd - thr) * 9;
		else
			sol += (snd + 40 - thr) * 9;
		cout << sol << endl;
		cin >> ini >> fst >> snd >> thr;
	}
	return 0;
}

No comments:

Post a Comment