結果

問題 No.491 10^9+1と回文
ユーザー GrenacheGrenache
提出日時 2017-03-10 23:26:26
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,510 bytes
コンパイル時間 3,871 ms
コンパイル使用メモリ 74,748 KB
実行使用メモリ 61,088 KB
最終ジャッジ日時 2023-09-06 14:20:31
合計ジャッジ時間 26,801 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 188 ms
58,892 KB
testcase_01 AC 191 ms
58,232 KB
testcase_02 AC 199 ms
58,224 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 192 ms
58,324 KB
testcase_08 AC 186 ms
58,208 KB
testcase_09 AC 187 ms
58,240 KB
testcase_10 AC 187 ms
59,164 KB
testcase_11 AC 187 ms
58,048 KB
testcase_12 AC 190 ms
58,268 KB
testcase_13 AC 186 ms
58,272 KB
testcase_14 WA -
testcase_15 AC 187 ms
58,480 KB
testcase_16 AC 186 ms
58,076 KB
testcase_17 AC 181 ms
57,972 KB
testcase_18 AC 189 ms
58,320 KB
testcase_19 AC 186 ms
58,188 KB
testcase_20 AC 188 ms
58,200 KB
testcase_21 AC 177 ms
58,004 KB
testcase_22 AC 190 ms
58,328 KB
testcase_23 WA -
testcase_24 AC 190 ms
58,780 KB
testcase_25 AC 198 ms
58,088 KB
testcase_26 AC 200 ms
58,076 KB
testcase_27 AC 178 ms
58,784 KB
testcase_28 AC 176 ms
58,760 KB
testcase_29 AC 188 ms
57,936 KB
testcase_30 AC 182 ms
58,588 KB
testcase_31 AC 193 ms
58,296 KB
testcase_32 AC 195 ms
58,280 KB
testcase_33 AC 190 ms
58,676 KB
testcase_34 AC 181 ms
57,940 KB
testcase_35 AC 195 ms
58,352 KB
testcase_36 AC 189 ms
58,228 KB
testcase_37 AC 177 ms
58,008 KB
testcase_38 AC 187 ms
58,228 KB
testcase_39 AC 187 ms
57,940 KB
testcase_40 AC 199 ms
58,024 KB
testcase_41 AC 191 ms
58,596 KB
testcase_42 AC 187 ms
58,292 KB
testcase_43 AC 189 ms
58,304 KB
testcase_44 AC 186 ms
58,320 KB
testcase_45 AC 195 ms
58,276 KB
testcase_46 AC 189 ms
58,128 KB
testcase_47 AC 194 ms
58,412 KB
testcase_48 AC 188 ms
58,104 KB
testcase_49 AC 192 ms
58,076 KB
testcase_50 AC 190 ms
58,736 KB
testcase_51 AC 194 ms
58,544 KB
testcase_52 AC 179 ms
58,196 KB
testcase_53 AC 185 ms
58,680 KB
testcase_54 AC 186 ms
58,676 KB
testcase_55 AC 199 ms
58,048 KB
testcase_56 AC 197 ms
57,808 KB
testcase_57 AC 189 ms
58,376 KB
testcase_58 WA -
testcase_59 AC 189 ms
58,640 KB
testcase_60 AC 195 ms
58,508 KB
testcase_61 AC 191 ms
58,176 KB
testcase_62 AC 189 ms
58,932 KB
testcase_63 WA -
testcase_64 AC 196 ms
58,064 KB
testcase_65 AC 195 ms
58,100 KB
testcase_66 AC 188 ms
58,020 KB
testcase_67 WA -
testcase_68 AC 195 ms
58,676 KB
testcase_69 AC 194 ms
58,664 KB
testcase_70 AC 187 ms
58,056 KB
testcase_71 AC 195 ms
58,244 KB
testcase_72 AC 177 ms
58,560 KB
testcase_73 AC 194 ms
58,536 KB
testcase_74 AC 198 ms
57,712 KB
testcase_75 AC 195 ms
57,772 KB
testcase_76 AC 190 ms
58,424 KB
testcase_77 AC 176 ms
58,084 KB
testcase_78 AC 176 ms
59,028 KB
testcase_79 AC 191 ms
58,424 KB
testcase_80 AC 187 ms
57,976 KB
testcase_81 AC 187 ms
58,356 KB
testcase_82 AC 183 ms
58,772 KB
testcase_83 AC 198 ms
58,412 KB
testcase_84 AC 186 ms
58,760 KB
testcase_85 AC 182 ms
58,604 KB
testcase_86 AC 187 ms
58,576 KB
testcase_87 AC 190 ms
59,164 KB
testcase_88 AC 186 ms
58,140 KB
testcase_89 AC 189 ms
58,356 KB
testcase_90 AC 192 ms
58,068 KB
testcase_91 AC 200 ms
58,040 KB
testcase_92 AC 184 ms
58,340 KB
testcase_93 AC 185 ms
58,296 KB
testcase_94 AC 197 ms
58,444 KB
testcase_95 AC 188 ms
58,048 KB
testcase_96 AC 190 ms
58,524 KB
testcase_97 WA -
testcase_98 WA -
testcase_99 WA -
testcase_100 WA -
testcase_101 WA -
testcase_102 WA -
testcase_103 WA -
testcase_104 WA -
testcase_105 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder491 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		long n = sc.nextLong();

		long t = 1_000_000_001;

		int ret = 0;
		for (int i = 1; i < 100000; i++) {
			if (i % 10 == 0) {
				continue;
			}

			StringBuilder tmp = new StringBuilder();
			tmp.append(i);
			if (t * i <= n) {
				if (isPalindrome(tmp)) {
					ret++;
				}
			}

			while (tmp.length() < 5) {
				tmp.insert(0, '0');
				int m = tmp.length();
				if (m * 2 < 6) {
					continue;
				}

				StringBuilder tmp2 = new StringBuilder();
				for (int j = 0; j < m; j++) {
					tmp2.append(tmp.charAt(m - 1 - j));
				}
				if (m == 5) {
					tmp2.deleteCharAt(m - 1);
				}
				for (int j = 0; j < m; j++) {
					tmp2.append(tmp.charAt(j));
				}

				long ltmp = Long.parseLong(tmp2.toString());
				if (t * ltmp <= n) {
					ret++;
				}
			}
		}

		pr.println(ret);
	}

	private static boolean isPalindrome(StringBuilder str) {
		int n = str.length();

		boolean flag = true;
		for (int i = 0; i < n / 2; i++) {
			if (str.charAt(i) != str.charAt(n - 1 - i)) {
				flag = false;
				break;
			}
		}

		return flag;
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0