(SPOJ) 8705 - Pedágio - 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);
}
void processa() throws NumberFormatException, IOException {
String line = "";
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
line = br.readLine();
StringTokenizer tokenizer = new StringTokenizer(line);
int distancia = Integer.valueOf(tokenizer.nextToken());
int distanciaEntrePedagio = Integer.valueOf(tokenizer.nextToken());
line = br.readLine();
tokenizer = new StringTokenizer(line);
int custoPorKM = Integer.valueOf(tokenizer.nextToken());
int custoPedagio = Integer.valueOf(tokenizer.nextToken());
System.out.println((custoPorKM*distancia)+((distancia/distanciaEntrePedagio)*custoPedagio));
return;
}
}
import java.util.*;
class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
Main processando = new Main();
processando.processa();
System.exit(0);
}
void processa() throws NumberFormatException, IOException {
String line = "";
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
line = br.readLine();
StringTokenizer tokenizer = new StringTokenizer(line);
int distancia = Integer.valueOf(tokenizer.nextToken());
int distanciaEntrePedagio = Integer.valueOf(tokenizer.nextToken());
line = br.readLine();
tokenizer = new StringTokenizer(line);
int custoPorKM = Integer.valueOf(tokenizer.nextToken());
int custoPedagio = Integer.valueOf(tokenizer.nextToken());
System.out.println((custoPorKM*distancia)+((distancia/distanciaEntrePedagio)*custoPedagio));
return;
}
}
Comments
Post a Comment