結果

問題 No.491 10^9+1と回文
ユーザー 37zigen37zigen
提出日時 2017-03-11 00:59:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 1,000 ms
コード長 986 bytes
コンパイル時間 2,241 ms
コンパイル使用メモリ 77,928 KB
実行使用メモリ 57,976 KB
最終ジャッジ日時 2024-04-08 16:08:58
合計ジャッジ時間 19,148 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
57,668 KB
testcase_01 AC 132 ms
57,696 KB
testcase_02 AC 135 ms
57,848 KB
testcase_03 AC 141 ms
57,732 KB
testcase_04 AC 137 ms
57,668 KB
testcase_05 AC 140 ms
57,700 KB
testcase_06 AC 140 ms
57,580 KB
testcase_07 AC 133 ms
57,824 KB
testcase_08 AC 134 ms
57,952 KB
testcase_09 AC 131 ms
55,868 KB
testcase_10 AC 135 ms
57,568 KB
testcase_11 AC 133 ms
57,680 KB
testcase_12 AC 131 ms
57,684 KB
testcase_13 AC 131 ms
55,716 KB
testcase_14 AC 132 ms
57,644 KB
testcase_15 AC 131 ms
57,676 KB
testcase_16 AC 136 ms
57,804 KB
testcase_17 AC 141 ms
57,568 KB
testcase_18 AC 131 ms
57,712 KB
testcase_19 AC 137 ms
57,652 KB
testcase_20 AC 135 ms
57,580 KB
testcase_21 AC 136 ms
57,576 KB
testcase_22 AC 134 ms
57,956 KB
testcase_23 AC 132 ms
57,696 KB
testcase_24 AC 130 ms
57,568 KB
testcase_25 AC 133 ms
57,836 KB
testcase_26 AC 133 ms
57,848 KB
testcase_27 AC 131 ms
57,688 KB
testcase_28 AC 131 ms
57,576 KB
testcase_29 AC 151 ms
57,604 KB
testcase_30 AC 133 ms
57,976 KB
testcase_31 AC 133 ms
57,544 KB
testcase_32 AC 134 ms
57,832 KB
testcase_33 AC 132 ms
57,592 KB
testcase_34 AC 132 ms
57,692 KB
testcase_35 AC 137 ms
57,548 KB
testcase_36 AC 134 ms
57,692 KB
testcase_37 AC 132 ms
57,580 KB
testcase_38 AC 129 ms
57,700 KB
testcase_39 AC 136 ms
57,576 KB
testcase_40 AC 132 ms
57,824 KB
testcase_41 AC 135 ms
57,804 KB
testcase_42 AC 135 ms
57,688 KB
testcase_43 AC 135 ms
57,676 KB
testcase_44 AC 129 ms
57,544 KB
testcase_45 AC 130 ms
57,800 KB
testcase_46 AC 129 ms
57,544 KB
testcase_47 AC 132 ms
57,812 KB
testcase_48 AC 143 ms
57,536 KB
testcase_49 AC 138 ms
57,676 KB
testcase_50 AC 135 ms
57,536 KB
testcase_51 AC 133 ms
57,676 KB
testcase_52 AC 135 ms
57,828 KB
testcase_53 AC 132 ms
57,804 KB
testcase_54 AC 137 ms
57,548 KB
testcase_55 AC 133 ms
57,968 KB
testcase_56 AC 135 ms
57,692 KB
testcase_57 AC 135 ms
57,592 KB
testcase_58 AC 134 ms
57,672 KB
testcase_59 AC 134 ms
57,664 KB
testcase_60 AC 133 ms
57,568 KB
testcase_61 AC 136 ms
57,948 KB
testcase_62 AC 133 ms
57,696 KB
testcase_63 AC 132 ms
56,120 KB
testcase_64 AC 132 ms
57,568 KB
testcase_65 AC 133 ms
57,556 KB
testcase_66 AC 130 ms
57,576 KB
testcase_67 AC 138 ms
57,696 KB
testcase_68 AC 134 ms
57,556 KB
testcase_69 AC 137 ms
57,692 KB
testcase_70 AC 130 ms
57,824 KB
testcase_71 AC 132 ms
57,548 KB
testcase_72 AC 131 ms
57,828 KB
testcase_73 AC 135 ms
57,568 KB
testcase_74 AC 134 ms
57,648 KB
testcase_75 AC 135 ms
57,548 KB
testcase_76 AC 133 ms
57,612 KB
testcase_77 AC 132 ms
57,560 KB
testcase_78 AC 133 ms
57,824 KB
testcase_79 AC 132 ms
57,580 KB
testcase_80 AC 137 ms
57,704 KB
testcase_81 AC 135 ms
57,840 KB
testcase_82 AC 136 ms
57,644 KB
testcase_83 AC 132 ms
55,696 KB
testcase_84 AC 130 ms
55,692 KB
testcase_85 AC 135 ms
55,696 KB
testcase_86 AC 132 ms
57,608 KB
testcase_87 AC 135 ms
57,600 KB
testcase_88 AC 136 ms
57,644 KB
testcase_89 AC 132 ms
57,580 KB
testcase_90 AC 136 ms
57,608 KB
testcase_91 AC 137 ms
55,568 KB
testcase_92 AC 134 ms
57,584 KB
testcase_93 AC 135 ms
57,576 KB
testcase_94 AC 134 ms
57,560 KB
testcase_95 AC 135 ms
57,644 KB
testcase_96 AC 136 ms
57,568 KB
testcase_97 AC 142 ms
57,648 KB
testcase_98 AC 138 ms
57,696 KB
testcase_99 AC 142 ms
57,568 KB
testcase_100 AC 139 ms
57,816 KB
testcase_101 AC 139 ms
57,716 KB
testcase_102 AC 142 ms
57,828 KB
testcase_103 AC 141 ms
57,548 KB
testcase_104 AC 139 ms
57,716 KB
testcase_105 AC 138 ms
57,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	static long N;
	static long FACTOR = 1_000_000_000 + 1;
	static long[] pow10 = new long[19];

	void run() {
		pow10[0] = 1;
		for (int i = 1; i < pow10.length; ++i)
			pow10[i] = pow10[i - 1] * 10;

		Scanner sc = new Scanner(System.in);
		N = sc.nextLong();
		long ans = 0;
		for (int i = 0; i <= 8; ++i) {
			ans += dfs(0, i, 0, true);
		}
		System.out.println(ans);
	}

	static long dfs(int s, int t, long cur, boolean f) {
		if (s > t) {
			if (cur > 0) {
				return 1;
			} else
				return 0;
		}
		long sum = 0;
		for (int i = (f ? 1 : 0); i < 10; ++i) {
			long tmp = cur + (pow10[s] + (s == t ? 0 : pow10[t])) * i;
			if (tmp * FACTOR <= N) {
				sum += dfs(s + 1, t - 1, tmp, false);
			}
		}
		return sum;
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
0