結果

問題 No.653 E869120 and Lucky Numbers
ユーザー htensaihtensai
提出日時 2020-01-08 11:38:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 1,410 bytes
コンパイル時間 2,107 ms
コンパイル使用メモリ 74,348 KB
実行使用メモリ 49,468 KB
最終ジャッジ日時 2023-10-11 19:28:58
合計ジャッジ時間 4,951 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,384 KB
testcase_01 AC 43 ms
49,104 KB
testcase_02 AC 43 ms
49,240 KB
testcase_03 AC 43 ms
49,052 KB
testcase_04 AC 43 ms
49,296 KB
testcase_05 AC 42 ms
49,060 KB
testcase_06 AC 42 ms
49,348 KB
testcase_07 AC 43 ms
49,108 KB
testcase_08 AC 44 ms
49,184 KB
testcase_09 AC 43 ms
49,188 KB
testcase_10 AC 43 ms
49,144 KB
testcase_11 AC 44 ms
49,348 KB
testcase_12 AC 43 ms
49,152 KB
testcase_13 AC 43 ms
49,164 KB
testcase_14 AC 44 ms
49,264 KB
testcase_15 AC 42 ms
49,052 KB
testcase_16 AC 43 ms
49,068 KB
testcase_17 AC 42 ms
49,124 KB
testcase_18 AC 44 ms
49,404 KB
testcase_19 AC 43 ms
47,192 KB
testcase_20 AC 43 ms
47,140 KB
testcase_21 AC 42 ms
49,156 KB
testcase_22 AC 42 ms
49,340 KB
testcase_23 AC 43 ms
49,096 KB
testcase_24 AC 43 ms
49,040 KB
testcase_25 AC 44 ms
49,216 KB
testcase_26 AC 44 ms
49,236 KB
testcase_27 AC 43 ms
49,100 KB
testcase_28 AC 46 ms
49,340 KB
testcase_29 AC 47 ms
49,136 KB
testcase_30 AC 46 ms
49,468 KB
testcase_31 AC 43 ms
49,392 KB
testcase_32 AC 43 ms
49,052 KB
testcase_33 AC 42 ms
49,232 KB
権限があれば一括ダウンロードができます

ソースコード

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