結果

問題 No.491 10^9+1と回文
ユーザー mosmos_21mosmos_21
提出日時 2017-06-19 20:11:32
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 1,339 bytes
コンパイル時間 3,026 ms
コンパイル使用メモリ 86,564 KB
実行使用メモリ 84,868 KB
最終ジャッジ日時 2024-04-10 06:11:27
合計ジャッジ時間 32,552 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
54,220 KB
testcase_01 AC 115 ms
53,356 KB
testcase_02 AC 117 ms
53,848 KB
testcase_03 MLE -
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
testcase_07 WA -
testcase_08 AC 118 ms
53,512 KB
testcase_09 AC 117 ms
54,212 KB
testcase_10 AC 116 ms
53,664 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 122 ms
53,832 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 119 ms
53,968 KB
testcase_18 AC 115 ms
53,848 KB
testcase_19 WA -
testcase_20 AC 117 ms
53,972 KB
testcase_21 WA -
testcase_22 AC 105 ms
52,828 KB
testcase_23 WA -
testcase_24 AC 118 ms
54,256 KB
testcase_25 AC 103 ms
52,548 KB
testcase_26 AC 102 ms
52,960 KB
testcase_27 AC 126 ms
54,172 KB
testcase_28 AC 116 ms
53,356 KB
testcase_29 AC 122 ms
53,844 KB
testcase_30 WA -
testcase_31 AC 116 ms
54,124 KB
testcase_32 WA -
testcase_33 AC 120 ms
54,332 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 122 ms
54,144 KB
testcase_37 AC 107 ms
53,044 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 117 ms
53,860 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 129 ms
54,016 KB
testcase_48 AC 109 ms
52,932 KB
testcase_49 AC 121 ms
54,240 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 118 ms
54,124 KB
testcase_54 AC 109 ms
52,728 KB
testcase_55 AC 124 ms
54,392 KB
testcase_56 AC 109 ms
52,960 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 AC 120 ms
54,028 KB
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 AC 111 ms
52,972 KB
testcase_66 AC 124 ms
54,208 KB
testcase_67 MLE -
testcase_68 WA -
testcase_69 AC 110 ms
52,932 KB
testcase_70 AC 119 ms
53,916 KB
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 AC 117 ms
54,132 KB
testcase_76 AC 122 ms
54,260 KB
testcase_77 AC 118 ms
54,052 KB
testcase_78 WA -
testcase_79 WA -
testcase_80 AC 115 ms
54,012 KB
testcase_81 AC 105 ms
52,976 KB
testcase_82 AC 121 ms
53,844 KB
testcase_83 WA -
testcase_84 AC 103 ms
52,948 KB
testcase_85 WA -
testcase_86 AC 118 ms
54,032 KB
testcase_87 WA -
testcase_88 AC 111 ms
53,340 KB
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 121 ms
53,992 KB
testcase_93 WA -
testcase_94 WA -
testcase_95 AC 118 ms
54,172 KB
testcase_96 WA -
testcase_97 TLE -
testcase_98 TLE -
testcase_99 TLE -
testcase_100 TLE -
testcase_101 TLE -
testcase_102 TLE -
testcase_103 TLE -
testcase_104 TLE -
testcase_105 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashSet;
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;
        for (int i : list) {
            if (max >= 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);
            for (int i = 1; i < 10; i++) {
                f(s + 1, i);
            }
        } 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 StringBuffer(n).reverse().toString();
            for (int i = 1; i < 11; i++) {
                list.add(Integer.parseInt(l + i + r));
                f(s + 1, n * 10 + i);
            }

        }
    }
}
0