-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathdst.java
More file actions
49 lines (40 loc) · 705 Bytes
/
dst.java
File metadata and controls
49 lines (40 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.Scanner;
public class dst {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int cases = scan.nextInt();
for (int zax = 0; zax < cases; zax++)
{
String roll = scan.next();
int amount = scan.nextInt();
int hours = scan.nextInt();
int mins = scan.nextInt();
if (roll.equals("F"))
{
hours += amount / 60;
mins += amount % 60;
if (mins >= 60)
{
mins %= 60;
hours++;
}
if (hours > 23)
hours %= 24;
}
else
{
hours -= amount / 60;
mins -= amount % 60;
if (mins < 0)
{
mins += 60;
hours--;
}
if (hours < 0)
hours += 24;
}
System.out.println(hours + " " + mins);
}
scan.close();
}
}