結果

問題 No.653 E869120 and Lucky Numbers
ユーザー htensaihtensai
提出日時 2020-01-08 11:05:11
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,400 bytes
コンパイル時間 3,625 ms
コンパイル使用メモリ 74,552 KB
実行使用メモリ 49,824 KB
最終ジャッジ日時 2023-08-15 00:24:58
合計ジャッジ時間 6,263 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,416 KB
testcase_01 AC 42 ms
49,432 KB
testcase_02 AC 42 ms
49,260 KB
testcase_03 AC 44 ms
49,368 KB
testcase_04 AC 42 ms
49,212 KB
testcase_05 AC 42 ms
49,068 KB
testcase_06 WA -
testcase_07 AC 41 ms
49,176 KB
testcase_08 AC 41 ms
49,144 KB
testcase_09 AC 40 ms
49,204 KB
testcase_10 WA -
testcase_11 AC 41 ms
49,588 KB
testcase_12 WA -
testcase_13 AC 41 ms
49,476 KB
testcase_14 AC 42 ms
49,176 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 42 ms
49,356 KB
testcase_18 AC 41 ms
49,728 KB
testcase_19 AC 42 ms
49,496 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 42 ms
49,356 KB
testcase_23 AC 42 ms
49,632 KB
testcase_24 WA -
testcase_25 AC 40 ms
49,168 KB
testcase_26 AC 41 ms
49,288 KB
testcase_27 AC 42 ms
49,220 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 45 ms
49,200 KB
testcase_31 AC 41 ms
49,112 KB
testcase_32 AC 43 ms
49,240 KB
testcase_33 AC 42 ms
49,188 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 = last - 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 != num) {
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }
}
0