結果

問題 No.491 10^9+1と回文
ユーザー GrenacheGrenache
提出日時 2017-03-10 23:37:41
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,513 bytes
コンパイル時間 4,634 ms
コンパイル使用メモリ 74,192 KB
実行使用メモリ 64,340 KB
最終ジャッジ日時 2023-09-06 14:34:00
合計ジャッジ時間 37,063 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 271 ms
61,668 KB
testcase_01 AC 264 ms
61,212 KB
testcase_02 AC 266 ms
60,960 KB
testcase_03 WA -
testcase_04 AC 267 ms
61,956 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 268 ms
61,808 KB
testcase_08 AC 261 ms
61,872 KB
testcase_09 AC 262 ms
61,988 KB
testcase_10 AC 265 ms
61,476 KB
testcase_11 AC 265 ms
61,836 KB
testcase_12 AC 267 ms
61,556 KB
testcase_13 AC 263 ms
61,620 KB
testcase_14 AC 274 ms
62,120 KB
testcase_15 AC 267 ms
62,068 KB
testcase_16 AC 260 ms
61,784 KB
testcase_17 AC 270 ms
61,480 KB
testcase_18 AC 267 ms
61,588 KB
testcase_19 AC 261 ms
62,016 KB
testcase_20 AC 270 ms
61,644 KB
testcase_21 AC 267 ms
62,256 KB
testcase_22 AC 265 ms
61,496 KB
testcase_23 AC 265 ms
61,296 KB
testcase_24 AC 262 ms
61,276 KB
testcase_25 AC 261 ms
61,752 KB
testcase_26 AC 270 ms
61,860 KB
testcase_27 AC 259 ms
61,420 KB
testcase_28 AC 264 ms
61,444 KB
testcase_29 AC 261 ms
61,388 KB
testcase_30 AC 263 ms
62,084 KB
testcase_31 AC 262 ms
61,564 KB
testcase_32 AC 267 ms
61,764 KB
testcase_33 AC 264 ms
61,992 KB
testcase_34 AC 272 ms
61,096 KB
testcase_35 AC 267 ms
62,008 KB
testcase_36 AC 261 ms
61,132 KB
testcase_37 AC 263 ms
62,024 KB
testcase_38 AC 264 ms
61,688 KB
testcase_39 AC 264 ms
62,000 KB
testcase_40 AC 261 ms
61,164 KB
testcase_41 AC 264 ms
62,188 KB
testcase_42 AC 259 ms
61,068 KB
testcase_43 AC 260 ms
61,792 KB
testcase_44 AC 260 ms
61,000 KB
testcase_45 AC 265 ms
61,328 KB
testcase_46 AC 261 ms
61,556 KB
testcase_47 AC 269 ms
61,680 KB
testcase_48 AC 264 ms
61,668 KB
testcase_49 AC 261 ms
61,376 KB
testcase_50 AC 262 ms
61,724 KB
testcase_51 AC 281 ms
61,952 KB
testcase_52 AC 265 ms
61,868 KB
testcase_53 AC 269 ms
62,148 KB
testcase_54 AC 260 ms
61,348 KB
testcase_55 AC 258 ms
61,244 KB
testcase_56 AC 263 ms
61,596 KB
testcase_57 AC 261 ms
61,712 KB
testcase_58 AC 268 ms
61,944 KB
testcase_59 AC 259 ms
61,604 KB
testcase_60 AC 266 ms
62,036 KB
testcase_61 AC 266 ms
61,584 KB
testcase_62 AC 257 ms
60,716 KB
testcase_63 AC 267 ms
62,084 KB
testcase_64 AC 260 ms
61,316 KB
testcase_65 AC 260 ms
61,456 KB
testcase_66 AC 269 ms
61,872 KB
testcase_67 WA -
testcase_68 AC 268 ms
61,692 KB
testcase_69 AC 270 ms
61,444 KB
testcase_70 AC 270 ms
62,072 KB
testcase_71 AC 264 ms
61,716 KB
testcase_72 AC 263 ms
61,976 KB
testcase_73 MLE -
testcase_74 AC 267 ms
61,552 KB
testcase_75 AC 270 ms
61,828 KB
testcase_76 AC 260 ms
61,548 KB
testcase_77 MLE -
testcase_78 AC 262 ms
62,144 KB
testcase_79 AC 266 ms
62,000 KB
testcase_80 AC 264 ms
61,752 KB
testcase_81 AC 265 ms
61,800 KB
testcase_82 AC 261 ms
61,840 KB
testcase_83 AC 264 ms
62,096 KB
testcase_84 AC 273 ms
61,784 KB
testcase_85 AC 289 ms
62,184 KB
testcase_86 AC 265 ms
61,624 KB
testcase_87 MLE -
testcase_88 AC 262 ms
61,520 KB
testcase_89 AC 261 ms
61,892 KB
testcase_90 AC 268 ms
61,680 KB
testcase_91 AC 260 ms
61,192 KB
testcase_92 AC 266 ms
59,116 KB
testcase_93 AC 266 ms
61,064 KB
testcase_94 AC 268 ms
61,968 KB
testcase_95 AC 262 ms
61,696 KB
testcase_96 AC 270 ms
61,052 KB
testcase_97 WA -
testcase_98 WA -
testcase_99 WA -
testcase_100 WA -
testcase_101 MLE -
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 < 100_000; 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) {
				int m = tmp.length();

				if (m * 2 >= 6) {
					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++;
					}
				}

				tmp.insert(0, '0');
			}
		}

		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