結果

問題 No.509 塗りつぶしツール
ユーザー shinwisteria
提出日時 2017-05-04 22:20:07
言語 Java
(openjdk 23)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 3,575 ms
コンパイル使用メモリ 75,740 KB
実行使用メモリ 41,572 KB
最終ジャッジ日時 2024-09-14 07:17:08
合計ジャッジ時間 8,396 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Nuritsubushi {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		StringBuilder n = new StringBuilder(s.next());
		s.close();
		int a = 0,b = 0,c = 0,count = 0;
		while(n.length() != 0){
			char ch = n.charAt(0);
			n.deleteCharAt(0);
			if(ch == '8'){
				c++;
			}else if(ch == '0' || ch == '4' || ch == '6' || ch == '9'){
				b++;
			}else{
				a++;
			}
		}
		count = a*2 + b*3 + c*4 + 1;
		count = Math.min(count, a + b*3 + c*5 + 2);
		System.out.println(count);
	}

}
0