Problem
My Solution
1import java.util.Scanner;
2
3public class Main {
4
5 public static void main(String[] args) {
6
7 Scanner sc = new Scanner(System.in);
8
9 while (sc.hasNext()) {
10
11 String temp[] = sc.nextLine().split(" ");
12 if (Integer.parseInt(temp[0]) == 0 && Integer.parseInt(temp[1]) == 0 && Integer.parseInt(temp[2]) == 0
13 && Integer.parseInt(temp[3]) == 0) {
14
15 break;
16 } else {
17 System.out.println(1080 + ((Integer.parseInt(temp[0]) - Integer.parseInt(temp[1]) + 40) % 40
18 + (Integer.parseInt(temp[2]) - Integer.parseInt(temp[1]) + 40) % 40
19 + (Integer.parseInt(temp[2]) - Integer.parseInt(temp[3]) + 40) % 40) * 9);
20 }
21 }
22
23 }
24}