結果

問題 No.653 E869120 and Lucky Numbers
ユーザー htensaihtensai
提出日時 2020-01-08 11:38:33
言語 Java
(openjdk 23)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 1,410 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 77,364 KB
実行使用メモリ 50,404 KB
最終ジャッジ日時 2024-09-13 18:20:23
合計ジャッジ時間 5,084 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] arr = br.readLine().toCharArray();
        int length = arr.length;
        int last = arr[length - 1] - '0';
        if (last < 2 || last > 4) {
            System.out.println("No");
            return;
        }
        int num = 0;
        for (int i = length - 2; i >= 0; i--) {
            int x = arr[i] - '0';
            if (num == 0) {
                if (i == 0) {
                    if (x == 1 || x == 7 || x == 8) {
                        System.out.println("Yes");
                    } else {
                        System.out.println("No");
                    }
                    return;
                }
                if (x - 1 >= 2 && x - 1 <= 4) {
                    continue;
                }
                if (x - 1 == 6) {
                    num = 6;
                } else if (x - 1 == 7) {
                    num = 7;
                } else {
                    System.out.println("No");
                    return;
                }
            } else {
                if (x != 6 && x != 7) {
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }
}
0