import java.util.BitSet;
import java.util.Scanner;
/**
* Solución a 10783 - Odd Sum [https://uva.onlinejudge.org/]
*
* @author BreakDark (Jhonny Monrroy)
* @version 1.0 24 nov. de 2017
*/
// Accepted!!! xD
public class Main {
public static void main(String[] args) {
Scanner Lee = new Scanner(System.in);
int t, a, b, i, j, sum;
BitSet impares = new BitSet(101);
for (i = 1; i <= 100; i += 2)
impares.set(i);
// AQUI INICIA EL PROGRAMA
t = Lee.nextInt();
for (i = 1; i <= t; i++) {
a = Lee.nextInt();
b = Lee.nextInt();
sum = 0;
for (j = a; j <= b; j++) {
if (impares.get(j))
sum += j;
}
System.out.println("Case " + i + ": " + sum);
}
Lee.close();
}
}
Blog dedicado a la publicación de artículos, programas propios, traducciones de Roms de Nes, super Nes y mas, y alguno que otro artículo sobre tecnologia.
Monday, January 22, 2018
Solución al problema: 10783 - Odd Sum con Java
Para ver el link del problema Click aqui
Subscribe to:
Post Comments (Atom)
1 comment:
buena solucion estaba buscando esto gracias.
Post a Comment