1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS09
* Problem: 10465 Homer Simpson
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1406
*
* @author Christoph Hausmann
* @version 0.1, 12/09/2009
*
* Method : Ad-hoc
* Status : Accepted
* Runtime: 1.648
*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class HomerSimpson_10465 {

public static void main(String... args) throws IOException {
final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

while(true) {
String curLine = br.readLine();

if(curLine == null)
return;

final String[] lineSplit = curLine.split(" ");

System.out.println(computeBurgersAndBeerTime(Integer.parseInt(lineSplit[0]),
Integer.parseInt(lineSplit[1]),
Integer.parseInt(lineSplit[2])));
}
}

private static String computeBurgersAndBeerTime(int m, int n, int t) {
if(m <= n && t%m == 0) {
return "" + t/m;
}
else if(m > n && t%n == 0) {
return "" + t/n;
}

final int maxX = t/m;

int maxBurgers = 0;
int minBeerTime = Integer.MAX_VALUE;

for(int x = 0; x <= maxX; x++) {
for(int y = 0; y <= (t-x*m)/n; y++) {
int curBeerTime = t - x*m - y*n;
int curMaxBurgers = x+y;

if(curBeerTime < minBeerTime) {
minBeerTime = curBeerTime;
maxBurgers = curMaxBurgers;
} else if(curBeerTime == minBeerTime) {
if(curMaxBurgers > maxBurgers)
maxBurgers = curMaxBurgers;
}

}
}



if(minBeerTime > 0)
return maxBurgers + " " + minBeerTime;
else
return "" + maxBurgers;
}
}