El enunciado esta en el siguiente link enunciado
import java.util.Scanner;
/**
* Problem A Roman Numerals [http://uva.onlinejudge.org]
*
* @author BreakDark
* @version 1.0 beta
*/
// ACEPTADO!!!
public class Main {
public static void main(String[] args) {
Scanner Lee;
short N;
byte i;
byte[][] valores = { { 0, 1, 2, 3, 3, 2, 3, 4, 5, 3 },
{ 0, 2, 4, 6, 4, 2, 4, 6, 8, 4 },
{ 0, 2, 4, 6, 5, 3, 5, 7, 9, 6 },
{ 0, 4, 8, 12, 0, 0, 0, 0, 0, 0 } };
byte sum;
// AQUI INICIA EL PROGRAMA
Lee = new Scanner(System.in);
while (Lee.hasNext()) {
N = Lee.nextShort();
i = 0;
sum = 0;
while (N > 0) {
sum += valores[i][N % 10];
N /= 10;
i++;
}
System.out.println(sum);
}
}
}
|
No comments:
Post a Comment