結果

問題 No.509 塗りつぶしツール
ユーザー takeya_okinotakeya_okino
提出日時 2017-09-30 20:27:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 1,831 ms
コンパイル使用メモリ 74,740 KB
実行使用メモリ 54,164 KB
最終ジャッジ日時 2024-04-27 16:59:18
合計ジャッジ時間 5,995 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
52,372 KB
testcase_01 AC 111 ms
53,800 KB
testcase_02 AC 99 ms
52,632 KB
testcase_03 AC 110 ms
53,804 KB
testcase_04 AC 111 ms
53,448 KB
testcase_05 AC 113 ms
53,932 KB
testcase_06 AC 113 ms
53,924 KB
testcase_07 AC 103 ms
52,756 KB
testcase_08 AC 103 ms
52,752 KB
testcase_09 AC 117 ms
54,052 KB
testcase_10 AC 111 ms
53,752 KB
testcase_11 AC 104 ms
52,656 KB
testcase_12 AC 113 ms
53,796 KB
testcase_13 AC 103 ms
52,512 KB
testcase_14 AC 113 ms
54,004 KB
testcase_15 AC 103 ms
52,776 KB
testcase_16 AC 106 ms
52,832 KB
testcase_17 AC 114 ms
53,752 KB
testcase_18 AC 99 ms
52,832 KB
testcase_19 AC 111 ms
53,956 KB
testcase_20 AC 121 ms
53,812 KB
testcase_21 AC 116 ms
53,508 KB
testcase_22 AC 109 ms
53,868 KB
testcase_23 AC 114 ms
54,028 KB
testcase_24 AC 120 ms
54,164 KB
testcase_25 AC 98 ms
52,468 KB
testcase_26 AC 98 ms
52,732 KB
testcase_27 AC 101 ms
52,568 KB
testcase_28 AC 116 ms
53,976 KB
testcase_29 AC 102 ms
52,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] num = new int[10];
    int r = 0;
    for(int i = 0; i < 10; i++) {
      int d = n % 10;
      num[d]++;
      r++;
      n /= 10;
      if(n == 0) break;
    }
    int ana = 0;
    for(int i = 0; i < 10; i++) {
      if((i == 0) || (i == 4) || (i == 6) || (i == 9)) ana += (num[i]);
      if(i == 8) ana += (2 * num[i]);
    }
    int ans1 = 2 * r + 1 + ana;
    int ans2 = r + (2 * ana) + 2;
    int ans = Math.min(ans1, ans2);
    System.out.println(ans);
  }
}
0