結果

問題 No.653 E869120 and Lucky Numbers
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-23 23:53:40
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,877 bytes
コンパイル時間 2,376 ms
コンパイル使用メモリ 77,656 KB
実行使用メモリ 41,580 KB
最終ジャッジ日時 2024-04-18 11:46:01
合計ジャッジ時間 6,723 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
41,220 KB
testcase_01 AC 102 ms
41,144 KB
testcase_02 AC 131 ms
41,000 KB
testcase_03 AC 113 ms
40,292 KB
testcase_04 AC 105 ms
41,088 KB
testcase_05 AC 109 ms
40,132 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 122 ms
40,176 KB
testcase_09 AC 111 ms
41,496 KB
testcase_10 AC 101 ms
39,996 KB
testcase_11 AC 100 ms
41,240 KB
testcase_12 AC 121 ms
41,188 KB
testcase_13 AC 113 ms
39,904 KB
testcase_14 AC 101 ms
40,980 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 109 ms
41,164 KB
testcase_18 AC 110 ms
41,212 KB
testcase_19 AC 108 ms
41,496 KB
testcase_20 AC 120 ms
41,148 KB
testcase_21 AC 98 ms
39,828 KB
testcase_22 AC 111 ms
41,084 KB
testcase_23 AC 111 ms
41,200 KB
testcase_24 AC 110 ms
41,228 KB
testcase_25 AC 105 ms
41,320 KB
testcase_26 AC 110 ms
40,916 KB
testcase_27 AC 93 ms
40,924 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 118 ms
41,116 KB
testcase_31 AC 117 ms
41,044 KB
testcase_32 AC 112 ms
40,072 KB
testcase_33 AC 109 ms
41,384 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 {
			for (int i=0; i<s.length(); i++) {
				if (i==0) {
					if (s.charAt(0)!='1') {return false;}
				}
				else if (i==s.length()-1) {
					char c = s.charAt(s.length()-1);
					if (c!='2' && c!='3' && c!='4') {return false;}
				}
				else {
					char c = s.charAt(i);
					if (c!='3' && c!='4' && c!='5') {return false;}
				}
			}
		}
		
		
		
		
		
		
		
		
		
		if (s.length()==1) {
			return false;
		}
		else if (s.length()==2) {
			if (s.equals("12")==false && s.equals("13")==false && s.equals("14")==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の場合
			else if (s.charAt(0)=='6' || s.charAt(0)=='7') {
				s = s.substring(0,s.length()-1);
				s = s.replaceAll("[345]","");
				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