結果
問題 | No.491 10^9+1と回文 |
ユーザー | Grenache |
提出日時 | 2017-03-11 00:19:15 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 248 ms / 1,000 ms |
コード長 | 1,853 bytes |
コンパイル時間 | 3,634 ms |
コンパイル使用メモリ | 79,196 KB |
実行使用メモリ | 60,884 KB |
最終ジャッジ日時 | 2024-10-01 08:25:32 |
合計ジャッジ時間 | 30,879 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 240 ms
59,732 KB |
testcase_01 | AC | 243 ms
60,056 KB |
testcase_02 | AC | 230 ms
59,288 KB |
testcase_03 | AC | 248 ms
59,824 KB |
testcase_04 | AC | 228 ms
59,476 KB |
testcase_05 | AC | 231 ms
59,176 KB |
testcase_06 | AC | 226 ms
59,780 KB |
testcase_07 | AC | 230 ms
59,924 KB |
testcase_08 | AC | 221 ms
59,300 KB |
testcase_09 | AC | 236 ms
60,416 KB |
testcase_10 | AC | 233 ms
59,948 KB |
testcase_11 | AC | 237 ms
59,720 KB |
testcase_12 | AC | 231 ms
59,984 KB |
testcase_13 | AC | 233 ms
60,208 KB |
testcase_14 | AC | 234 ms
60,000 KB |
testcase_15 | AC | 232 ms
59,736 KB |
testcase_16 | AC | 238 ms
60,032 KB |
testcase_17 | AC | 242 ms
59,616 KB |
testcase_18 | AC | 232 ms
59,280 KB |
testcase_19 | AC | 231 ms
59,920 KB |
testcase_20 | AC | 230 ms
59,288 KB |
testcase_21 | AC | 229 ms
60,388 KB |
testcase_22 | AC | 220 ms
59,400 KB |
testcase_23 | AC | 228 ms
59,820 KB |
testcase_24 | AC | 227 ms
59,864 KB |
testcase_25 | AC | 235 ms
60,184 KB |
testcase_26 | AC | 213 ms
59,412 KB |
testcase_27 | AC | 236 ms
59,716 KB |
testcase_28 | AC | 236 ms
59,556 KB |
testcase_29 | AC | 231 ms
59,344 KB |
testcase_30 | AC | 237 ms
59,836 KB |
testcase_31 | AC | 230 ms
59,436 KB |
testcase_32 | AC | 230 ms
59,792 KB |
testcase_33 | AC | 239 ms
59,840 KB |
testcase_34 | AC | 225 ms
58,940 KB |
testcase_35 | AC | 227 ms
59,460 KB |
testcase_36 | AC | 222 ms
59,500 KB |
testcase_37 | AC | 235 ms
59,888 KB |
testcase_38 | AC | 236 ms
59,744 KB |
testcase_39 | AC | 235 ms
59,584 KB |
testcase_40 | AC | 234 ms
60,332 KB |
testcase_41 | AC | 227 ms
59,192 KB |
testcase_42 | AC | 229 ms
59,228 KB |
testcase_43 | AC | 217 ms
59,508 KB |
testcase_44 | AC | 222 ms
59,412 KB |
testcase_45 | AC | 219 ms
59,368 KB |
testcase_46 | AC | 234 ms
60,252 KB |
testcase_47 | AC | 221 ms
59,036 KB |
testcase_48 | AC | 236 ms
59,700 KB |
testcase_49 | AC | 230 ms
59,392 KB |
testcase_50 | AC | 225 ms
60,220 KB |
testcase_51 | AC | 220 ms
59,080 KB |
testcase_52 | AC | 232 ms
59,264 KB |
testcase_53 | AC | 232 ms
59,700 KB |
testcase_54 | AC | 238 ms
60,068 KB |
testcase_55 | AC | 224 ms
59,308 KB |
testcase_56 | AC | 237 ms
59,264 KB |
testcase_57 | AC | 248 ms
60,312 KB |
testcase_58 | AC | 239 ms
60,424 KB |
testcase_59 | AC | 228 ms
59,952 KB |
testcase_60 | AC | 225 ms
60,156 KB |
testcase_61 | AC | 240 ms
60,184 KB |
testcase_62 | AC | 227 ms
59,304 KB |
testcase_63 | AC | 216 ms
60,020 KB |
testcase_64 | AC | 234 ms
60,132 KB |
testcase_65 | AC | 234 ms
59,244 KB |
testcase_66 | AC | 237 ms
59,592 KB |
testcase_67 | AC | 227 ms
59,492 KB |
testcase_68 | AC | 228 ms
59,384 KB |
testcase_69 | AC | 240 ms
59,972 KB |
testcase_70 | AC | 230 ms
59,400 KB |
testcase_71 | AC | 224 ms
59,920 KB |
testcase_72 | AC | 212 ms
59,360 KB |
testcase_73 | AC | 222 ms
59,348 KB |
testcase_74 | AC | 242 ms
60,884 KB |
testcase_75 | AC | 221 ms
59,532 KB |
testcase_76 | AC | 215 ms
59,248 KB |
testcase_77 | AC | 228 ms
58,696 KB |
testcase_78 | AC | 216 ms
59,040 KB |
testcase_79 | AC | 224 ms
59,572 KB |
testcase_80 | AC | 223 ms
59,160 KB |
testcase_81 | AC | 217 ms
58,972 KB |
testcase_82 | AC | 224 ms
59,544 KB |
testcase_83 | AC | 231 ms
59,640 KB |
testcase_84 | AC | 237 ms
60,212 KB |
testcase_85 | AC | 230 ms
60,096 KB |
testcase_86 | AC | 235 ms
59,372 KB |
testcase_87 | AC | 233 ms
59,992 KB |
testcase_88 | AC | 228 ms
59,104 KB |
testcase_89 | AC | 215 ms
59,204 KB |
testcase_90 | AC | 240 ms
60,328 KB |
testcase_91 | AC | 234 ms
59,844 KB |
testcase_92 | AC | 226 ms
59,052 KB |
testcase_93 | AC | 230 ms
59,804 KB |
testcase_94 | AC | 239 ms
59,788 KB |
testcase_95 | AC | 239 ms
59,228 KB |
testcase_96 | AC | 238 ms
59,784 KB |
testcase_97 | AC | 230 ms
60,020 KB |
testcase_98 | AC | 230 ms
59,956 KB |
testcase_99 | AC | 247 ms
60,444 KB |
testcase_100 | AC | 247 ms
59,888 KB |
testcase_101 | AC | 219 ms
59,768 KB |
testcase_102 | AC | 214 ms
60,004 KB |
testcase_103 | AC | 235 ms
60,632 KB |
testcase_104 | AC | 232 ms
59,804 KB |
testcase_105 | AC | 220 ms
58,940 KB |
ソースコード
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 < 10_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() <= 4) { int m = tmp.length(); 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 (ltmp > 9999 && ltmp < 1_000_000_000 && t * ltmp <= n) { ret++; } for (int c = 0; c < 10; c++) { tmp2 = new StringBuilder(); for (int j = 0; j < m; j++) { tmp2.append(tmp.charAt(m - 1 - j)); } tmp2.append((char)('0' + c)); for (int j = 0; j < m; j++) { tmp2.append(tmp.charAt(j)); } ltmp = Long.parseLong(tmp2.toString()); if (ltmp > 9999 && ltmp < 1_000_000_000 && 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); } } }