結果

問題 No.491 10^9+1と回文
ユーザー mosmos_21mosmos_21
提出日時 2017-06-19 20:29:42
言語 Java21
(openjdk 21)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,515 bytes
コンパイル時間 2,495 ms
コンパイル使用メモリ 85,224 KB
実行使用メモリ 76,824 KB
最終ジャッジ日時 2024-04-10 06:12:01
合計ジャッジ時間 27,329 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
54,096 KB
testcase_01 AC 135 ms
54,160 KB
testcase_02 AC 134 ms
54,168 KB
testcase_03 AC 320 ms
63,384 KB
testcase_04 AC 201 ms
55,228 KB
testcase_05 AC 275 ms
57,656 KB
testcase_06 MLE -
testcase_07 AC 192 ms
55,320 KB
testcase_08 AC 128 ms
53,888 KB
testcase_09 AC 129 ms
54,376 KB
testcase_10 AC 126 ms
54,244 KB
testcase_11 AC 168 ms
55,388 KB
testcase_12 AC 171 ms
55,380 KB
testcase_13 AC 125 ms
54,012 KB
testcase_14 AC 200 ms
55,312 KB
testcase_15 AC 207 ms
55,180 KB
testcase_16 AC 178 ms
55,160 KB
testcase_17 AC 132 ms
54,400 KB
testcase_18 AC 136 ms
54,332 KB
testcase_19 AC 165 ms
55,184 KB
testcase_20 AC 134 ms
53,868 KB
testcase_21 AC 181 ms
55,156 KB
testcase_22 AC 130 ms
53,888 KB
testcase_23 AC 204 ms
55,420 KB
testcase_24 AC 130 ms
54,364 KB
testcase_25 AC 130 ms
54,276 KB
testcase_26 AC 131 ms
54,328 KB
testcase_27 AC 131 ms
54,344 KB
testcase_28 AC 131 ms
54,160 KB
testcase_29 AC 129 ms
53,908 KB
testcase_30 AC 198 ms
55,648 KB
testcase_31 AC 131 ms
54,116 KB
testcase_32 AC 201 ms
55,596 KB
testcase_33 AC 129 ms
54,248 KB
testcase_34 AC 180 ms
55,052 KB
testcase_35 AC 195 ms
55,044 KB
testcase_36 AC 126 ms
54,564 KB
testcase_37 AC 129 ms
54,408 KB
testcase_38 AC 171 ms
55,068 KB
testcase_39 AC 182 ms
55,124 KB
testcase_40 AC 132 ms
54,236 KB
testcase_41 AC 171 ms
55,252 KB
testcase_42 AC 174 ms
54,896 KB
testcase_43 AC 174 ms
55,200 KB
testcase_44 AC 180 ms
55,100 KB
testcase_45 AC 178 ms
55,172 KB
testcase_46 AC 184 ms
55,204 KB
testcase_47 AC 130 ms
54,168 KB
testcase_48 AC 136 ms
54,460 KB
testcase_49 AC 135 ms
54,308 KB
testcase_50 AC 179 ms
54,984 KB
testcase_51 AC 196 ms
55,472 KB
testcase_52 AC 173 ms
54,920 KB
testcase_53 AC 117 ms
53,064 KB
testcase_54 AC 134 ms
54,272 KB
testcase_55 AC 134 ms
54,200 KB
testcase_56 AC 134 ms
54,556 KB
testcase_57 AC 179 ms
55,344 KB
testcase_58 AC 211 ms
55,680 KB
testcase_59 AC 185 ms
55,372 KB
testcase_60 AC 179 ms
54,920 KB
testcase_61 AC 133 ms
54,224 KB
testcase_62 AC 185 ms
55,180 KB
testcase_63 AC 211 ms
55,292 KB
testcase_64 AC 185 ms
55,248 KB
testcase_65 AC 138 ms
54,268 KB
testcase_66 AC 137 ms
54,172 KB
testcase_67 MLE -
testcase_68 AC 195 ms
55,424 KB
testcase_69 AC 135 ms
54,396 KB
testcase_70 AC 137 ms
54,080 KB
testcase_71 AC 207 ms
55,492 KB
testcase_72 AC 191 ms
55,160 KB
testcase_73 AC 187 ms
55,168 KB
testcase_74 AC 185 ms
55,284 KB
testcase_75 AC 135 ms
54,160 KB
testcase_76 AC 139 ms
54,148 KB
testcase_77 AC 138 ms
54,244 KB
testcase_78 AC 165 ms
55,184 KB
testcase_79 AC 166 ms
55,472 KB
testcase_80 AC 126 ms
54,000 KB
testcase_81 AC 134 ms
54,276 KB
testcase_82 AC 135 ms
54,208 KB
testcase_83 AC 185 ms
55,128 KB
testcase_84 AC 135 ms
54,364 KB
testcase_85 AC 182 ms
55,348 KB
testcase_86 AC 134 ms
54,012 KB
testcase_87 AC 177 ms
55,136 KB
testcase_88 AC 138 ms
54,004 KB
testcase_89 AC 184 ms
55,164 KB
testcase_90 AC 185 ms
55,428 KB
testcase_91 AC 186 ms
55,492 KB
testcase_92 AC 133 ms
54,340 KB
testcase_93 AC 189 ms
54,964 KB
testcase_94 AC 207 ms
55,196 KB
testcase_95 AC 136 ms
54,000 KB
testcase_96 AC 179 ms
55,400 KB
testcase_97 MLE -
testcase_98 MLE -
testcase_99 MLE -
testcase_100 MLE -
testcase_101 MLE -
testcase_102 MLE -
testcase_103 MLE -
testcase_104 MLE -
testcase_105 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
    static Scanner in = new Scanner(System.in);
    static Set<Integer> list = new HashSet<>();
    static int max;

    public static void main(String[] args) {
        max = (int) (in.nextLong() / ((long) 1e9 + 1));
        for (int i = 1; i < 10; i++) {
            f(1, i);
        }
        int ans = 0;
        List<Integer> sortList = new ArrayList<>(list);
        Collections.sort(sortList);
        for (int i : sortList) {
            if (max >= i) {
                //System.out.println(i);
                ans++;
            }
        }
        System.out.println(ans);
    }

    public static void f(int s, int n) {
        if (s > String.valueOf(max).length()) {
            return;
        }
        if (s == 1) {
            list.add(n);
            f(s + 1, n);
        } else if (s % 2 == 0) {
            String l = String.valueOf(n);
            String r = (new StringBuilder(String.valueOf(n))).reverse().toString();
            list.add(Integer.parseInt(l + r));
            f(s + 1, n);
        } else if (s % 2 == 1) {
            String l = String.valueOf(n);
            String r = (new StringBuilder(String.valueOf(n))).reverse().toString();
            for (int i = 0; i < 10; i++) {
                list.add(Integer.parseInt(l + i + r));
                f(s + 1, n * 10 + i);
            }

        }
    }
}
0