結果
問題 | No.296 n度寝 |
ユーザー |
|
提出日時 | 2019-01-16 17:19:08 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 136 ms / 1,000 ms |
コード長 | 1,421 bytes |
コンパイル時間 | 2,146 ms |
コンパイル使用メモリ | 77,592 KB |
実行使用メモリ | 41,568 KB |
最終ジャッジ日時 | 2024-06-28 10:52:13 |
合計ジャッジ時間 | 5,085 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
ソースコード
import java.util.*; import java.math.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int h = sc.nextInt(); int m = sc.nextInt(); int t = sc.nextInt(); Time time = new Time(h, m); if (n <= 1) { time.getTime(); System.exit(0); } time.setMin((n - 1) * t); time.getTime(); } } class Time { private int hour; private int min; public Time(int a, int b) { hour = a; min = b; } public void setTime(int a, int b) { if (min + b >= 60) { hour++; this.min = Math.abs(min - b); } else { this.min += b; } if (hour + a >= 24) { this.hour = Math.abs((24 - this.hour) - a); } else { this.hour += a; } } public void setMin(int a) { int m = this.min + a; int h = this.hour; if (m >= 60) { h = this.hour + (int)Math.floor(m / 60); m = m % 60; } if (h >= 24) { h = h % 24; } this.hour = h; this.min = m; } public void getTime() { System.out.println(this.hour); System.out.println(this.min); } }