結果

問題 No.491 10^9+1と回文
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-06-20 02:20:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 251 ms / 1,000 ms
コード長 979 bytes
コンパイル時間 4,212 ms
コンパイル使用メモリ 77,796 KB
実行使用メモリ 60,576 KB
最終ジャッジ日時 2023-09-13 07:19:21
合計ジャッジ時間 22,490 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,092 KB
testcase_01 AC 124 ms
55,544 KB
testcase_02 AC 125 ms
55,964 KB
testcase_03 AC 173 ms
58,648 KB
testcase_04 AC 142 ms
55,820 KB
testcase_05 AC 175 ms
58,168 KB
testcase_06 AC 246 ms
58,648 KB
testcase_07 AC 135 ms
56,172 KB
testcase_08 AC 123 ms
56,112 KB
testcase_09 AC 124 ms
56,280 KB
testcase_10 AC 122 ms
56,068 KB
testcase_11 AC 124 ms
55,956 KB
testcase_12 AC 129 ms
55,728 KB
testcase_13 AC 122 ms
55,800 KB
testcase_14 AC 139 ms
55,948 KB
testcase_15 AC 131 ms
56,356 KB
testcase_16 AC 124 ms
55,952 KB
testcase_17 AC 123 ms
56,060 KB
testcase_18 AC 125 ms
56,032 KB
testcase_19 AC 128 ms
56,084 KB
testcase_20 AC 124 ms
55,712 KB
testcase_21 AC 127 ms
55,832 KB
testcase_22 AC 126 ms
55,692 KB
testcase_23 AC 139 ms
58,292 KB
testcase_24 AC 125 ms
56,004 KB
testcase_25 AC 125 ms
56,452 KB
testcase_26 AC 124 ms
56,224 KB
testcase_27 AC 126 ms
55,940 KB
testcase_28 AC 124 ms
55,928 KB
testcase_29 AC 125 ms
56,116 KB
testcase_30 AC 135 ms
55,864 KB
testcase_31 AC 121 ms
56,104 KB
testcase_32 AC 135 ms
55,996 KB
testcase_33 AC 124 ms
56,116 KB
testcase_34 AC 129 ms
55,876 KB
testcase_35 AC 139 ms
55,820 KB
testcase_36 AC 123 ms
56,044 KB
testcase_37 AC 123 ms
55,928 KB
testcase_38 AC 124 ms
56,156 KB
testcase_39 AC 125 ms
56,456 KB
testcase_40 AC 122 ms
55,928 KB
testcase_41 AC 128 ms
55,756 KB
testcase_42 AC 123 ms
55,520 KB
testcase_43 AC 124 ms
56,008 KB
testcase_44 AC 128 ms
55,736 KB
testcase_45 AC 124 ms
55,860 KB
testcase_46 AC 132 ms
55,876 KB
testcase_47 AC 125 ms
56,092 KB
testcase_48 AC 123 ms
55,796 KB
testcase_49 AC 119 ms
55,672 KB
testcase_50 AC 126 ms
56,144 KB
testcase_51 AC 137 ms
56,132 KB
testcase_52 AC 125 ms
55,548 KB
testcase_53 AC 122 ms
55,864 KB
testcase_54 AC 124 ms
56,144 KB
testcase_55 AC 125 ms
55,900 KB
testcase_56 AC 124 ms
55,928 KB
testcase_57 AC 125 ms
56,108 KB
testcase_58 AC 138 ms
56,108 KB
testcase_59 AC 127 ms
55,824 KB
testcase_60 AC 124 ms
56,168 KB
testcase_61 AC 123 ms
56,004 KB
testcase_62 AC 127 ms
55,896 KB
testcase_63 AC 137 ms
56,008 KB
testcase_64 AC 128 ms
56,020 KB
testcase_65 AC 126 ms
56,352 KB
testcase_66 AC 126 ms
55,864 KB
testcase_67 AC 173 ms
58,408 KB
testcase_68 AC 129 ms
56,084 KB
testcase_69 AC 123 ms
55,688 KB
testcase_70 AC 123 ms
56,260 KB
testcase_71 AC 136 ms
55,752 KB
testcase_72 AC 129 ms
55,652 KB
testcase_73 AC 132 ms
56,252 KB
testcase_74 AC 127 ms
56,116 KB
testcase_75 AC 124 ms
55,860 KB
testcase_76 AC 125 ms
56,240 KB
testcase_77 AC 122 ms
55,960 KB
testcase_78 AC 128 ms
56,124 KB
testcase_79 AC 129 ms
55,888 KB
testcase_80 AC 125 ms
55,872 KB
testcase_81 AC 125 ms
55,888 KB
testcase_82 AC 126 ms
55,544 KB
testcase_83 AC 130 ms
55,896 KB
testcase_84 AC 123 ms
56,156 KB
testcase_85 AC 130 ms
56,136 KB
testcase_86 AC 122 ms
55,744 KB
testcase_87 AC 126 ms
55,592 KB
testcase_88 AC 122 ms
55,500 KB
testcase_89 AC 126 ms
55,828 KB
testcase_90 AC 130 ms
56,204 KB
testcase_91 AC 130 ms
55,592 KB
testcase_92 AC 126 ms
55,836 KB
testcase_93 AC 133 ms
55,920 KB
testcase_94 AC 137 ms
55,792 KB
testcase_95 AC 123 ms
56,304 KB
testcase_96 AC 125 ms
55,864 KB
testcase_97 AC 186 ms
58,684 KB
testcase_98 AC 251 ms
58,856 KB
testcase_99 AC 236 ms
58,800 KB
testcase_100 AC 227 ms
58,692 KB
testcase_101 AC 224 ms
58,944 KB
testcase_102 AC 226 ms
58,280 KB
testcase_103 AC 247 ms
59,996 KB
testcase_104 AC 244 ms
60,576 KB
testcase_105 AC 250 ms
59,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
	}
}
0