UVA 10783 Java
import java.util.*; public class main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int times = sc.nextInt(); for(int i = 0; i < times; i++) { int a = sc.nextInt(); int b = sc.nextInt(); int sum = 0; for(int j = a; j <= b; j++) if(j % 2 != 0) sum += j; System.out.println(String.format("Case %d: %d", i+1, sum)); } } };
留言
張貼留言