結果

問題 No.653 E869120 and Lucky Numbers
ユーザー tentententen
提出日時 2020-09-05 05:56:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 2,202 ms
コンパイル使用メモリ 73,984 KB
実行使用メモリ 56,400 KB
最終ジャッジ日時 2023-10-11 19:30:39
合計ジャッジ時間 8,084 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,764 KB
testcase_01 AC 135 ms
56,008 KB
testcase_02 AC 136 ms
55,876 KB
testcase_03 AC 138 ms
55,544 KB
testcase_04 AC 128 ms
55,728 KB
testcase_05 AC 130 ms
56,124 KB
testcase_06 AC 135 ms
55,876 KB
testcase_07 AC 124 ms
55,732 KB
testcase_08 AC 134 ms
56,400 KB
testcase_09 AC 123 ms
55,772 KB
testcase_10 AC 122 ms
55,464 KB
testcase_11 AC 120 ms
55,732 KB
testcase_12 AC 121 ms
55,724 KB
testcase_13 AC 121 ms
55,444 KB
testcase_14 AC 121 ms
55,456 KB
testcase_15 AC 121 ms
55,764 KB
testcase_16 AC 122 ms
55,840 KB
testcase_17 AC 121 ms
55,664 KB
testcase_18 AC 121 ms
55,932 KB
testcase_19 AC 120 ms
55,728 KB
testcase_20 AC 119 ms
55,744 KB
testcase_21 AC 121 ms
55,924 KB
testcase_22 AC 119 ms
55,736 KB
testcase_23 AC 122 ms
55,844 KB
testcase_24 AC 122 ms
56,372 KB
testcase_25 AC 120 ms
55,904 KB
testcase_26 AC 120 ms
56,148 KB
testcase_27 AC 119 ms
55,752 KB
testcase_28 AC 141 ms
53,924 KB
testcase_29 AC 142 ms
56,096 KB
testcase_30 AC 142 ms
55,852 KB
testcase_31 AC 121 ms
55,616 KB
testcase_32 AC 121 ms
55,492 KB
testcase_33 AC 121 ms
55,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	char[] arr = sc.next().toCharArray();
    	int length = arr.length;
    	if (arr[length - 1] < '2' || arr[length - 1] > '4') {
    	    System.out.println("No");
    	    return;
    	}
    	boolean flag = false;
    	for (int i = length - 2; i >= 1; i--) {
    	    if (flag) {
    	        if (arr[i] < '6' || arr[i] > '7') {
    	            System.out.println("No");
    	            return;
    	        }
    	    } else {
    	        if (arr[i] >= '3' && arr[i] <= '5') {
    	            continue;
    	        } else if (arr[i] >= '7' && arr[i] <= '8') {
    	            flag = true;
    	        } else {
    	            System.out.println("No");
    	            return;
    	        }
    	    }
    	}
    	if (flag) {
	        if (arr[0] < '6' || arr[0] > '7') {
	            System.out.println("No");
	        } else {
	            System.out.println("Yes");
	        }
    	} else {
    	    if (arr[0] == '1' || arr[0] == '7' || arr[0] == '8') {
	            System.out.println("Yes");
    	    } else {
	            System.out.println("No");
    	    }
    	}
	}
}
0