結果

問題 No.653 E869120 and Lucky Numbers
ユーザー tetsutetsu
提出日時 2018-02-23 23:20:51
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,850 bytes
コンパイル時間 3,265 ms
コンパイル使用メモリ 77,600 KB
実行使用メモリ 52,808 KB
最終ジャッジ日時 2024-04-18 09:59:39
合計ジャッジ時間 6,291 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
50,004 KB
testcase_01 AC 54 ms
50,316 KB
testcase_02 AC 51 ms
50,008 KB
testcase_03 AC 52 ms
50,140 KB
testcase_04 AC 55 ms
50,256 KB
testcase_05 AC 54 ms
50,288 KB
testcase_06 WA -
testcase_07 AC 51 ms
50,120 KB
testcase_08 AC 54 ms
50,116 KB
testcase_09 AC 55 ms
50,104 KB
testcase_10 AC 54 ms
50,360 KB
testcase_11 AC 52 ms
50,424 KB
testcase_12 AC 53 ms
50,216 KB
testcase_13 AC 52 ms
49,884 KB
testcase_14 AC 53 ms
49,876 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 53 ms
50,164 KB
testcase_18 AC 52 ms
50,332 KB
testcase_19 AC 52 ms
50,160 KB
testcase_20 AC 52 ms
50,268 KB
testcase_21 AC 52 ms
50,336 KB
testcase_22 AC 51 ms
49,892 KB
testcase_23 AC 49 ms
50,136 KB
testcase_24 AC 52 ms
50,296 KB
testcase_25 AC 52 ms
49,980 KB
testcase_26 AC 52 ms
50,244 KB
testcase_27 AC 52 ms
50,272 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 77 ms
50,760 KB
testcase_31 AC 53 ms
50,372 KB
testcase_32 AC 49 ms
50,344 KB
testcase_33 AC 49 ms
50,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class C {

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		String p = sc.next();
		int[] ds = new int[20000];
		for(int i=0; i<p.length(); i++) {
			ds[i] = Character.getNumericValue(p.charAt(p.length()-1-i));
		}
		for(int i=0; i<p.length(); i++) {
			if(i==p.length()-1) {
				if(ds[i]==0 || ds[i]==7 || ds[i]==6) {
					System.out.println("Yes");
					return;
				} else {
					System.out.println("No");
					return;
				}
			}
			if(ds[i]==2||ds[i]==3||ds[i]==4) {
				if(ds[i+1]>=1) {
					ds[i+1]--;
				} else {
					boolean f = false;
					int j=i+2;
					while(j<p.length() && ds[j]==0) {
						ds[j]=9;
						j++;
					}
					if(j<p.length()) {
						ds[j]--;
						f = true;
					}
					if(f) {
						ds[i+1]--;
					} else {
						System.out.println("No");
						return;
					}
				}
			} else {
				System.out.println("No");
				return;
			}
		}
	}

	static class MyScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public MyScanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
			
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
}
0