1.

#include <stdio.h>

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS11
* Problem: 10465 Homer Simpson
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1406
*
* @author Bastian Hoecker
* @author Philipp Hauck Thalheim
* @version 1.0, 13/13/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.348
*/

int main() {

int krusty, apu, max, result, bestApprox, resultApprox, m, n, restTime;

while(scanf("%d %d %d", &krusty, &apu, &max) != EOF) {
result = 0;
bestApprox = 10000;
resultApprox = -1;
restTime = 0;

for (m = 0; m <= max; m += krusty) {
for (n = 0; n + m <= max; n += apu) {

if (max - m - n <= bestApprox) {
bestApprox = max - m - n;
if (resultApprox == bestApprox) {
result = (result > m / krusty + n / apu) ? result : m / krusty + n / apu;
} else {
result = m / krusty + n / apu;
resultApprox = bestApprox;
}
restTime = bestApprox;
}
}
}

printf("%d", result);
if (restTime != 0)
printf(" %d\n", restTime);
else
printf("\n");

}

return 0;
}



---------------------------------------------------------------------------------------------

1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS10/11
* Problem: 10465 - Homer Simpson
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1406
*
* @author Manuel Hager
* @version 1.0, 11/15/2010
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.276
*/

#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
unsigned int krustyBurger, kwik_e_Mart, burgerTotal;
unsigned int minTime, maxTime;
unsigned int burger, beer;

while(cin >> krustyBurger >> kwik_e_Mart >> burgerTotal) {

minTime = min(krustyBurger, kwik_e_Mart);
maxTime = max(krustyBurger, kwik_e_Mart);

if(krustyBurger > burgerTotal && kwik_e_Mart > burgerTotal) {
cout << "0 " << burgerTotal << endl;
}
else if(krustyBurger > burgerTotal || kwik_e_Mart > burgerTotal || krustyBurger == kwik_e_Mart) {
burger = burgerTotal / minTime;
beer = burgerTotal - burger * minTime;
if(beer)
cout << burger << " " << beer << endl;
else
cout << burger << endl;
}
else {
int rest = burgerTotal % minTime;
burger = burgerTotal / minTime;
beer = rest;

bool sthFound = false;

if(rest) {
for(int min = (burgerTotal / minTime) * minTime; min >= 0 && !sthFound; min -= minTime) {
for(int max = maxTime; max + min <= burgerTotal && !sthFound; max += maxTime) {
int tmp = burgerTotal - (min + max);
if((max - rest) % minTime == 0) {
burger = (max / maxTime) + (min / minTime);
cout << burger << endl;
sthFound = true;
}

else if(tmp < beer) {
beer = tmp;
burger = max / maxTime + min / minTime;
if(tmp == 0) {
cout << burger << endl;
sthFound = true;
}
}
}
}
if(!sthFound)
cout << burger << " " << beer << endl;
}
else {
cout << burger << endl;
}
}
}
return 0;
}



2.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS2010
* Problem: Homer Simpson 10465
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1406
*
* @author Barny Porcio
* @version 1.0, 06/27/2010
*
* Status : Accepted
* Runtime: 0.884
*/
import java.io.IOException;
import java.util.Scanner;


public class Homer_Simpson_10465 {

/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
// StringTokenizer read = new StringTokenizer(br.readLine());
int m = sc.nextInt();//Integer.parseInt(read.nextToken());
int n = sc.nextInt();//Integer.parseInt(read.nextToken());
int t = sc.nextInt();//Integer.parseInt(read.nextToken());
if (n < m){
int temp = m;
m = n;
n = temp;
}
int[] ans = new int[2];
ans[1] = Integer.MAX_VALUE;
for (int i = t /m; i >=0;--i){
int rest = t-(i*m);
if (rest%n == 0 ){
ans[0] = i + rest/n;
ans[1] = 0;
break;
}
else if (rest%n < ans[1]){
ans[0] = i + rest/n;
ans[1] = rest %n;
}
}
if (ans[1] == 0)
System.out.println(ans[0]);
else{
System.out.println(ans[0]+" "+ans[1]);
}

}

}

}