Monday, August 3, 2015

UVa 10465 - Homer Simpson

// UVa 10465 - Homer Simpson

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

int main() {
	int m, n, t;
	while (cin >> m >> n >> t) {
		int tt = t - min(m, n);
		int T[20001];
		memset(T, 255, sizeof(T));
		int oo = T[0];
		T[0] = 0;
		for (int i = 0; i <= tt; i++)
			if (T[i] != oo) {
				T[i + m] = max(T[i + m], T[i] + 1);
				T[i + n] = max(T[i + n], T[i] + 1);
			}
		int s = t;
		while (T[s] == oo)
			s--;
		if (s == t)
			cout << T[s] << endl;
		else
			cout << T[s] << " " << t - s << endl;
	}

	return 0;
}

No comments:

Post a Comment