結果

問題 No.653 E869120 and Lucky Numbers
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-24 00:07:49
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,722 bytes
コンパイル時間 2,241 ms
コンパイル使用メモリ 74,164 KB
実行使用メモリ 58,884 KB
最終ジャッジ日時 2023-08-25 23:07:30
合計ジャッジ時間 6,863 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
55,760 KB
testcase_01 AC 114 ms
56,456 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 130 ms
56,468 KB
testcase_07 AC 112 ms
56,552 KB
testcase_08 AC 138 ms
56,648 KB
testcase_09 AC 100 ms
55,944 KB
testcase_10 AC 99 ms
55,328 KB
testcase_11 AC 103 ms
56,212 KB
testcase_12 AC 102 ms
55,692 KB
testcase_13 AC 101 ms
55,992 KB
testcase_14 AC 103 ms
56,084 KB
testcase_15 AC 100 ms
55,692 KB
testcase_16 AC 99 ms
56,008 KB
testcase_17 AC 102 ms
56,420 KB
testcase_18 AC 101 ms
56,076 KB
testcase_19 AC 103 ms
56,024 KB
testcase_20 AC 98 ms
55,724 KB
testcase_21 AC 102 ms
56,300 KB
testcase_22 AC 100 ms
55,812 KB
testcase_23 AC 98 ms
55,784 KB
testcase_24 AC 101 ms
56,028 KB
testcase_25 AC 96 ms
55,980 KB
testcase_26 AC 104 ms
55,816 KB
testcase_27 AC 103 ms
55,684 KB
testcase_28 AC 154 ms
58,516 KB
testcase_29 AC 159 ms
57,156 KB
testcase_30 AC 157 ms
56,604 KB
testcase_31 AC 99 ms
55,944 KB
testcase_32 AC 98 ms
56,024 KB
testcase_33 AC 99 ms
55,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String s = sc.next();
		System.out.println(judge(s)==true?"Yes":"No");
	}
	
	static boolean judge (String s) {
		
		if (s.length()==1) {
			return false;
		}
		else if (s.length()==2) {
			if (s.equals("12")==false && s.equals("13")==false && s.equals("14")==false) {
				if (s.equals("72")==false && s.equals("73")==false && s.equals("74")==false) {
					if (s.equals("82")==false && s.equals("83")==false && s.equals("84")==false) {
						return false;
					}
				}
			}
		}
		else {
			char c = s.charAt(0);
			if (c!='1' && c!='6' && c!='7' && c!='8') {return false;}
			c = s.charAt(s.length()-1);
			if (c!='2' && c!='3' && c!='4') {return false;}
			
			//先頭が1の場合
			if (s.charAt(0)=='1') {
				for (int i=1; i<s.length()-1; i++) {
					c = s.charAt(i);
					if (c!='3' && c!='4' && c!='5') {return false;}
				}
				return true;
			}
			//先頭が6か7か8の場合
			else if (s.charAt(0)=='6' || s.charAt(0)=='7' || s.charAt(0)=='8') {
				s = s.substring(0,s.length()-1);
				s = s.replaceAll("[345]","");
				
				if (s.charAt(s.length()-1)=='6') {return false;}
				
				String[] ar = {"1","2","3","4","5","9","0"};
				for (int i=0; i<ar.length; i++) {
					if (s.contains(ar[i])) {return false;}
				}
				//もし8が含まれているならそれはただ一つであり一番右側か?
				
				if (s.contains("8")) {
					for (int i=0; i<s.length(); i++) {
						if (i!=s.length()-1) {
							if (s.charAt(i)=='8') {return false;}
						}
					}
				}
				s = s.replaceAll("[678]","");
				if (s.equals("")==false) {return false;}
			}
		}
		return true;
	}
}
0