結果

問題 No.296 n度寝
ユーザー masamasa
提出日時 2019-01-16 17:18:10
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,421 bytes
コンパイル時間 3,719 ms
コンパイル使用メモリ 73,820 KB
実行使用メモリ 57,568 KB
最終ジャッジ日時 2023-09-10 19:43:46
合計ジャッジ時間 6,956 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,876 KB
testcase_01 AC 126 ms
55,728 KB
testcase_02 AC 127 ms
55,360 KB
testcase_03 AC 126 ms
55,568 KB
testcase_04 RE -
testcase_05 AC 127 ms
55,636 KB
testcase_06 RE -
testcase_07 AC 127 ms
55,808 KB
testcase_08 AC 127 ms
55,548 KB
testcase_09 AC 126 ms
56,004 KB
testcase_10 RE -
testcase_11 AC 127 ms
55,724 KB
testcase_12 AC 126 ms
55,924 KB
testcase_13 RE -
testcase_14 AC 125 ms
56,088 KB
testcase_15 AC 128 ms
55,996 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(1);
        }
        
        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