(SPOJ) 20007 - Receita de Bolo - Solução
import java.io.*;
import java.util.*;
class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
Main processando = new Main();
processando.processa();
System.exit(0);
}
static int leitor(BufferedReader br) throws NumberFormatException, IOException {
int n;
int resp = 0;
while (true) {
n = br.read();
if (n >= '0' && n <= '9') break;
}
while (true) {
resp = resp*10 + n-'0';
n = br.read();
if (n < '0' || n > '9') break;
}
return resp;
}
void processa() throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int trigo = leitor(br)/2;
int ovo = leitor(br)/3;
int leite = leitor(br)/5;
if (trigo <= ovo && trigo <= leite) {
bw.write(trigo + "\n");
}
else if (ovo <= trigo && ovo <= leite) {
bw.write(ovo + "\n");
}
else if (leite <= ovo && leite <= trigo) {
bw.write(leite + "\n");
}
bw.flush();
bw.close();
return;
}
}
import java.util.*;
class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
Main processando = new Main();
processando.processa();
System.exit(0);
}
static int leitor(BufferedReader br) throws NumberFormatException, IOException {
int n;
int resp = 0;
while (true) {
n = br.read();
if (n >= '0' && n <= '9') break;
}
while (true) {
resp = resp*10 + n-'0';
n = br.read();
if (n < '0' || n > '9') break;
}
return resp;
}
void processa() throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int trigo = leitor(br)/2;
int ovo = leitor(br)/3;
int leite = leitor(br)/5;
if (trigo <= ovo && trigo <= leite) {
bw.write(trigo + "\n");
}
else if (ovo <= trigo && ovo <= leite) {
bw.write(ovo + "\n");
}
else if (leite <= ovo && leite <= trigo) {
bw.write(leite + "\n");
}
bw.flush();
bw.close();
return;
}
}
Comments
Post a Comment