fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6. int N = sc.nextInt();
  7. int i = 1;
  8. int X;
  9. int Y;
  10. while (true) {
  11.  
  12. if (i > N) {
  13. break;
  14. }
  15. else{
  16. X = sc.nextInt();
  17. Y = sc.nextInt();
  18. }
  19. int MIN = Math.min(X, Y);
  20. int MAX = Math.max(X, Y);
  21. int sum = 0;
  22. for (int j = MIN+1 ; j < MAX; j++) {
  23. if (j % 2 != 0) {
  24. sum = sum + j;
  25. }
  26. }
  27.  
  28. System.out.printf("%d\n", (sum));
  29.  
  30. i++;
  31. }
  32. sc.close();
  33.  
  34. }
  35. }
Success #stdin #stdout 0.19s 56732KB
stdin
3
5 6
10 4
4 9
stdout
0
21
12