結果

問題 No.491 10^9+1と回文
ユーザー GrenacheGrenache
提出日時 2017-03-10 23:49:53
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,657 bytes
コンパイル時間 3,564 ms
コンパイル使用メモリ 74,972 KB
実行使用メモリ 65,700 KB
最終ジャッジ日時 2023-09-06 14:42:25
合計ジャッジ時間 30,813 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 288 ms
63,452 KB
testcase_01 AC 226 ms
62,772 KB
testcase_02 AC 230 ms
63,016 KB
testcase_03 WA -
testcase_04 MLE -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 237 ms
63,864 KB
testcase_08 AC 245 ms
61,420 KB
testcase_09 AC 229 ms
63,056 KB
testcase_10 AC 232 ms
63,108 KB
testcase_11 AC 226 ms
62,860 KB
testcase_12 AC 227 ms
61,592 KB
testcase_13 AC 227 ms
62,752 KB
testcase_14 AC 234 ms
63,556 KB
testcase_15 AC 235 ms
62,720 KB
testcase_16 AC 270 ms
63,312 KB
testcase_17 AC 231 ms
63,000 KB
testcase_18 AC 228 ms
61,744 KB
testcase_19 AC 250 ms
61,400 KB
testcase_20 AC 225 ms
62,484 KB
testcase_21 AC 231 ms
63,484 KB
testcase_22 AC 233 ms
63,224 KB
testcase_23 AC 288 ms
63,476 KB
testcase_24 AC 229 ms
63,000 KB
testcase_25 AC 235 ms
63,140 KB
testcase_26 AC 231 ms
62,848 KB
testcase_27 AC 226 ms
62,832 KB
testcase_28 AC 282 ms
62,952 KB
testcase_29 MLE -
testcase_30 AC 287 ms
63,388 KB
testcase_31 AC 238 ms
63,060 KB
testcase_32 AC 282 ms
63,752 KB
testcase_33 AC 228 ms
62,716 KB
testcase_34 AC 233 ms
63,232 KB
testcase_35 AC 234 ms
63,276 KB
testcase_36 AC 225 ms
63,080 KB
testcase_37 MLE -
testcase_38 AC 227 ms
63,132 KB
testcase_39 MLE -
testcase_40 AC 226 ms
62,708 KB
testcase_41 AC 225 ms
63,336 KB
testcase_42 MLE -
testcase_43 AC 224 ms
62,852 KB
testcase_44 AC 240 ms
62,748 KB
testcase_45 AC 236 ms
63,048 KB
testcase_46 AC 227 ms
63,164 KB
testcase_47 AC 222 ms
62,684 KB
testcase_48 AC 231 ms
63,252 KB
testcase_49 AC 282 ms
62,692 KB
testcase_50 AC 269 ms
62,960 KB
testcase_51 AC 232 ms
63,424 KB
testcase_52 AC 226 ms
62,952 KB
testcase_53 AC 240 ms
62,872 KB
testcase_54 MLE -
testcase_55 AC 229 ms
63,568 KB
testcase_56 AC 292 ms
63,252 KB
testcase_57 MLE -
testcase_58 AC 240 ms
63,568 KB
testcase_59 AC 234 ms
63,092 KB
testcase_60 AC 289 ms
63,556 KB
testcase_61 AC 234 ms
62,892 KB
testcase_62 AC 232 ms
62,760 KB
testcase_63 AC 243 ms
63,260 KB
testcase_64 AC 276 ms
63,148 KB
testcase_65 AC 230 ms
62,108 KB
testcase_66 AC 230 ms
63,228 KB
testcase_67 WA -
testcase_68 AC 280 ms
63,264 KB
testcase_69 MLE -
testcase_70 AC 253 ms
61,560 KB
testcase_71 AC 237 ms
63,572 KB
testcase_72 AC 231 ms
63,796 KB
testcase_73 AC 230 ms
63,504 KB
testcase_74 MLE -
testcase_75 AC 227 ms
62,768 KB
testcase_76 AC 237 ms
63,096 KB
testcase_77 AC 237 ms
62,908 KB
testcase_78 AC 232 ms
62,804 KB
testcase_79 AC 230 ms
63,168 KB
testcase_80 AC 239 ms
63,636 KB
testcase_81 AC 230 ms
62,500 KB
testcase_82 MLE -
testcase_83 AC 229 ms
62,816 KB
testcase_84 AC 233 ms
62,676 KB
testcase_85 AC 230 ms
63,056 KB
testcase_86 AC 232 ms
63,116 KB
testcase_87 AC 232 ms
62,760 KB
testcase_88 AC 229 ms
63,288 KB
testcase_89 AC 237 ms
63,020 KB
testcase_90 AC 242 ms
63,404 KB
testcase_91 AC 236 ms
63,280 KB
testcase_92 AC 230 ms
63,052 KB
testcase_93 AC 232 ms
62,944 KB
testcase_94 AC 233 ms
63,504 KB
testcase_95 AC 231 ms
62,760 KB
testcase_96 AC 284 ms
63,128 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 MLE -
権限があれば一括ダウンロードができます

ソースコード

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));
					}
					for (int j = 0; j < m; j++) {
						tmp2.append(tmp.charAt(j));
					}
					long ltmp = Long.parseLong(tmp2.toString());
					if (m * 2 < 10 && t * ltmp <= n) {
						ret++;
					}

					if (tmp2.charAt(m - 1) != '0') {
						tmp2.deleteCharAt(m - 1);
						ltmp = Long.parseLong(tmp2.toString());
						if (ltmp > 99999 && 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