結果
問題 | No.491 10^9+1と回文 |
ユーザー | Daigo HIROOKA |
提出日時 | 2018-06-20 02:20:04 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 247 ms / 1,000 ms |
コード長 | 979 bytes |
コンパイル時間 | 3,503 ms |
コンパイル使用メモリ | 80,836 KB |
実行使用メモリ | 48,880 KB |
最終ジャッジ日時 | 2024-06-30 17:23:32 |
合計ジャッジ時間 | 20,633 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 112 ms
40,152 KB |
testcase_01 | AC | 119 ms
41,788 KB |
testcase_02 | AC | 128 ms
41,388 KB |
testcase_03 | AC | 162 ms
44,936 KB |
testcase_04 | AC | 142 ms
41,412 KB |
testcase_05 | AC | 168 ms
44,020 KB |
testcase_06 | AC | 241 ms
47,292 KB |
testcase_07 | AC | 125 ms
41,560 KB |
testcase_08 | AC | 124 ms
41,668 KB |
testcase_09 | AC | 116 ms
39,848 KB |
testcase_10 | AC | 124 ms
41,380 KB |
testcase_11 | AC | 115 ms
40,172 KB |
testcase_12 | AC | 115 ms
40,208 KB |
testcase_13 | AC | 112 ms
40,112 KB |
testcase_14 | AC | 156 ms
41,880 KB |
testcase_15 | AC | 115 ms
40,176 KB |
testcase_16 | AC | 130 ms
41,184 KB |
testcase_17 | AC | 127 ms
41,336 KB |
testcase_18 | AC | 128 ms
41,384 KB |
testcase_19 | AC | 126 ms
41,512 KB |
testcase_20 | AC | 130 ms
41,396 KB |
testcase_21 | AC | 135 ms
40,972 KB |
testcase_22 | AC | 129 ms
41,520 KB |
testcase_23 | AC | 143 ms
41,760 KB |
testcase_24 | AC | 130 ms
41,532 KB |
testcase_25 | AC | 124 ms
41,452 KB |
testcase_26 | AC | 124 ms
41,240 KB |
testcase_27 | AC | 114 ms
40,812 KB |
testcase_28 | AC | 124 ms
41,260 KB |
testcase_29 | AC | 124 ms
41,228 KB |
testcase_30 | AC | 144 ms
41,516 KB |
testcase_31 | AC | 128 ms
41,236 KB |
testcase_32 | AC | 136 ms
41,576 KB |
testcase_33 | AC | 134 ms
41,504 KB |
testcase_34 | AC | 137 ms
41,540 KB |
testcase_35 | AC | 142 ms
41,640 KB |
testcase_36 | AC | 121 ms
41,312 KB |
testcase_37 | AC | 126 ms
41,256 KB |
testcase_38 | AC | 115 ms
39,980 KB |
testcase_39 | AC | 130 ms
41,484 KB |
testcase_40 | AC | 124 ms
41,540 KB |
testcase_41 | AC | 134 ms
41,244 KB |
testcase_42 | AC | 133 ms
41,520 KB |
testcase_43 | AC | 132 ms
41,540 KB |
testcase_44 | AC | 127 ms
41,400 KB |
testcase_45 | AC | 117 ms
40,388 KB |
testcase_46 | AC | 128 ms
41,220 KB |
testcase_47 | AC | 118 ms
41,120 KB |
testcase_48 | AC | 128 ms
41,372 KB |
testcase_49 | AC | 109 ms
39,928 KB |
testcase_50 | AC | 130 ms
41,424 KB |
testcase_51 | AC | 151 ms
41,500 KB |
testcase_52 | AC | 115 ms
40,180 KB |
testcase_53 | AC | 123 ms
41,132 KB |
testcase_54 | AC | 127 ms
41,232 KB |
testcase_55 | AC | 126 ms
41,464 KB |
testcase_56 | AC | 127 ms
41,328 KB |
testcase_57 | AC | 132 ms
41,256 KB |
testcase_58 | AC | 138 ms
40,348 KB |
testcase_59 | AC | 132 ms
41,800 KB |
testcase_60 | AC | 129 ms
41,452 KB |
testcase_61 | AC | 130 ms
41,284 KB |
testcase_62 | AC | 113 ms
40,216 KB |
testcase_63 | AC | 146 ms
41,364 KB |
testcase_64 | AC | 123 ms
41,564 KB |
testcase_65 | AC | 121 ms
41,104 KB |
testcase_66 | AC | 124 ms
41,332 KB |
testcase_67 | AC | 179 ms
45,148 KB |
testcase_68 | AC | 128 ms
41,248 KB |
testcase_69 | AC | 120 ms
41,640 KB |
testcase_70 | AC | 109 ms
40,304 KB |
testcase_71 | AC | 143 ms
41,652 KB |
testcase_72 | AC | 124 ms
41,080 KB |
testcase_73 | AC | 130 ms
41,172 KB |
testcase_74 | AC | 126 ms
41,444 KB |
testcase_75 | AC | 125 ms
41,136 KB |
testcase_76 | AC | 127 ms
41,384 KB |
testcase_77 | AC | 127 ms
41,444 KB |
testcase_78 | AC | 134 ms
41,388 KB |
testcase_79 | AC | 127 ms
41,284 KB |
testcase_80 | AC | 118 ms
41,296 KB |
testcase_81 | AC | 121 ms
41,224 KB |
testcase_82 | AC | 107 ms
40,040 KB |
testcase_83 | AC | 132 ms
41,452 KB |
testcase_84 | AC | 120 ms
41,004 KB |
testcase_85 | AC | 130 ms
41,256 KB |
testcase_86 | AC | 121 ms
41,496 KB |
testcase_87 | AC | 108 ms
40,132 KB |
testcase_88 | AC | 124 ms
41,348 KB |
testcase_89 | AC | 115 ms
40,352 KB |
testcase_90 | AC | 132 ms
41,048 KB |
testcase_91 | AC | 135 ms
41,340 KB |
testcase_92 | AC | 123 ms
41,188 KB |
testcase_93 | AC | 119 ms
41,264 KB |
testcase_94 | AC | 131 ms
40,436 KB |
testcase_95 | AC | 120 ms
41,668 KB |
testcase_96 | AC | 120 ms
41,096 KB |
testcase_97 | AC | 183 ms
45,036 KB |
testcase_98 | AC | 246 ms
48,880 KB |
testcase_99 | AC | 230 ms
46,956 KB |
testcase_100 | AC | 229 ms
46,936 KB |
testcase_101 | AC | 210 ms
46,064 KB |
testcase_102 | AC | 229 ms
46,456 KB |
testcase_103 | AC | 247 ms
47,352 KB |
testcase_104 | AC | 247 ms
47,576 KB |
testcase_105 | AC | 245 ms
47,024 KB |
ソースコード
import java.util.*; import java.io.*; public class No491{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); long N = sc.nextLong(); long tmp = (long)Math.pow(10, 9) + 1; if(N < tmp) System.out.println(0); else{ long div = N/tmp; String s = String.valueOf(div); int l = s.length(); long ans = 0; for(int i = 1; i <= l; i++){ int start; if(i%2 != 0) start = (int)Math.pow(10, i/2); else start = (int)Math.pow(10, i/2-1); for(int d = start; d < 10*start; d++){ int mirror = symmetry(d, i%2!=0); if(mirror > div) break; else ans++; } } System.out.println(ans); } } private static int symmetry(int n, boolean odd){ String s = String.valueOf(n); int l = s.length(); StringBuilder sb; if(odd){ sb = new StringBuilder(s.substring(0, l-1)); }else{ sb = new StringBuilder(s); } int mirror = Integer.parseInt(s+sb.reverse().toString()); return mirror; } }