結果

問題 No.296 n度寝
ユーザー masamasa
提出日時 2019-01-16 17:19:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 1,000 ms
コード長 1,421 bytes
コンパイル時間 1,915 ms
コンパイル使用メモリ 73,860 KB
実行使用メモリ 56,368 KB
最終ジャッジ日時 2023-09-10 19:45:52
合計ジャッジ時間 4,860 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,904 KB
testcase_01 AC 125 ms
55,792 KB
testcase_02 AC 120 ms
55,724 KB
testcase_03 AC 119 ms
56,020 KB
testcase_04 AC 119 ms
55,760 KB
testcase_05 AC 119 ms
55,476 KB
testcase_06 AC 118 ms
55,488 KB
testcase_07 AC 120 ms
55,724 KB
testcase_08 AC 121 ms
55,796 KB
testcase_09 AC 122 ms
55,864 KB
testcase_10 AC 121 ms
55,484 KB
testcase_11 AC 123 ms
55,756 KB
testcase_12 AC 122 ms
55,848 KB
testcase_13 AC 121 ms
53,952 KB
testcase_14 AC 123 ms
55,956 KB
testcase_15 AC 125 ms
56,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
    }
}
0