結果

問題 No.779 Heisei
ユーザー kohaku_kohaku
提出日時 2019-02-19 21:48:06
言語 Java
(openjdk 23)
結果
AC  
実行時間 256 ms / 1,000 ms
コード長 1,049 bytes
コンパイル時間 3,341 ms
コンパイル使用メモリ 87,604 KB
実行使用メモリ 58,064 KB
最終ジャッジ日時 2024-11-06 05:15:54
合計ジャッジ時間 9,999 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.text.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int y = sc.nextInt();
        int m = sc.nextInt();
        int d = sc.nextInt();
        solve(y, m, d);
    }
    
    static void solve(int y, int m, int d) throws Exception {
        DateFormat df = new SimpleDateFormat("yyyyMMdd");
        String str = String.format("%04d", y) + String.format("%02d", m) + String.format("%02d", d);
        Calendar target = prepareCalendar(str, df);
        Calendar begin = prepareCalendar("19890108", df);
        Calendar end = prepareCalendar("20190430", df);
        if( !begin.after(target) && !end.before(target) ) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
    
    static Calendar prepareCalendar(String s, DateFormat df) throws Exception {
        Calendar cal = Calendar.getInstance();
        cal.setTime(df.parse(s));
        return cal;
    }
    
}
0