結果

問題 No.491 10^9+1と回文
ユーザー shinwisteriashinwisteria
提出日時 2017-03-23 23:28:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 1,000 ms
コード長 882 bytes
コンパイル時間 4,376 ms
コンパイル使用メモリ 77,964 KB
実行使用メモリ 58,080 KB
最終ジャッジ日時 2024-04-08 16:26:56
合計ジャッジ時間 20,562 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
57,592 KB
testcase_01 AC 135 ms
57,692 KB
testcase_02 AC 135 ms
55,600 KB
testcase_03 AC 135 ms
57,560 KB
testcase_04 AC 133 ms
57,696 KB
testcase_05 AC 138 ms
57,548 KB
testcase_06 AC 131 ms
57,560 KB
testcase_07 AC 135 ms
57,544 KB
testcase_08 AC 140 ms
57,588 KB
testcase_09 AC 134 ms
57,552 KB
testcase_10 AC 135 ms
57,704 KB
testcase_11 AC 135 ms
57,576 KB
testcase_12 AC 131 ms
57,712 KB
testcase_13 AC 131 ms
57,560 KB
testcase_14 AC 136 ms
57,544 KB
testcase_15 AC 137 ms
57,588 KB
testcase_16 AC 134 ms
57,980 KB
testcase_17 AC 133 ms
57,956 KB
testcase_18 AC 131 ms
57,560 KB
testcase_19 AC 133 ms
57,564 KB
testcase_20 AC 133 ms
57,704 KB
testcase_21 AC 137 ms
57,696 KB
testcase_22 AC 132 ms
57,580 KB
testcase_23 AC 135 ms
57,824 KB
testcase_24 AC 136 ms
57,680 KB
testcase_25 AC 136 ms
58,076 KB
testcase_26 AC 132 ms
57,948 KB
testcase_27 AC 138 ms
57,592 KB
testcase_28 AC 132 ms
57,704 KB
testcase_29 AC 132 ms
57,568 KB
testcase_30 AC 134 ms
57,648 KB
testcase_31 AC 131 ms
57,548 KB
testcase_32 AC 135 ms
57,640 KB
testcase_33 AC 135 ms
57,556 KB
testcase_34 AC 133 ms
57,832 KB
testcase_35 AC 134 ms
57,848 KB
testcase_36 AC 134 ms
57,824 KB
testcase_37 AC 132 ms
57,816 KB
testcase_38 AC 133 ms
57,800 KB
testcase_39 AC 133 ms
57,840 KB
testcase_40 AC 135 ms
57,568 KB
testcase_41 AC 133 ms
57,676 KB
testcase_42 AC 131 ms
57,576 KB
testcase_43 AC 136 ms
57,820 KB
testcase_44 AC 130 ms
57,828 KB
testcase_45 AC 132 ms
57,680 KB
testcase_46 AC 133 ms
57,568 KB
testcase_47 AC 136 ms
57,972 KB
testcase_48 AC 138 ms
57,952 KB
testcase_49 AC 133 ms
57,828 KB
testcase_50 AC 139 ms
57,572 KB
testcase_51 AC 138 ms
57,564 KB
testcase_52 AC 138 ms
58,032 KB
testcase_53 AC 136 ms
57,572 KB
testcase_54 AC 145 ms
57,592 KB
testcase_55 AC 137 ms
55,660 KB
testcase_56 AC 142 ms
57,536 KB
testcase_57 AC 141 ms
57,832 KB
testcase_58 AC 135 ms
57,548 KB
testcase_59 AC 134 ms
57,592 KB
testcase_60 AC 136 ms
57,692 KB
testcase_61 AC 137 ms
57,760 KB
testcase_62 AC 136 ms
57,604 KB
testcase_63 AC 137 ms
55,636 KB
testcase_64 AC 138 ms
57,824 KB
testcase_65 AC 143 ms
57,564 KB
testcase_66 AC 136 ms
57,664 KB
testcase_67 AC 137 ms
57,812 KB
testcase_68 AC 134 ms
57,928 KB
testcase_69 AC 137 ms
57,700 KB
testcase_70 AC 132 ms
57,832 KB
testcase_71 AC 134 ms
57,820 KB
testcase_72 AC 134 ms
57,572 KB
testcase_73 AC 134 ms
58,080 KB
testcase_74 AC 132 ms
57,548 KB
testcase_75 AC 134 ms
57,696 KB
testcase_76 AC 134 ms
55,864 KB
testcase_77 AC 135 ms
57,692 KB
testcase_78 AC 136 ms
56,040 KB
testcase_79 AC 134 ms
57,696 KB
testcase_80 AC 136 ms
57,592 KB
testcase_81 AC 132 ms
57,716 KB
testcase_82 AC 133 ms
57,796 KB
testcase_83 AC 135 ms
57,560 KB
testcase_84 AC 131 ms
57,696 KB
testcase_85 AC 133 ms
57,564 KB
testcase_86 AC 131 ms
57,828 KB
testcase_87 AC 137 ms
57,556 KB
testcase_88 AC 135 ms
57,700 KB
testcase_89 AC 136 ms
57,592 KB
testcase_90 AC 137 ms
57,588 KB
testcase_91 AC 138 ms
57,548 KB
testcase_92 AC 134 ms
57,676 KB
testcase_93 AC 136 ms
57,576 KB
testcase_94 AC 136 ms
57,548 KB
testcase_95 AC 134 ms
57,568 KB
testcase_96 AC 136 ms
57,832 KB
testcase_97 AC 136 ms
57,588 KB
testcase_98 AC 137 ms
57,552 KB
testcase_99 AC 138 ms
57,800 KB
testcase_100 AC 137 ms
57,792 KB
testcase_101 AC 136 ms
57,804 KB
testcase_102 AC 139 ms
57,568 KB
testcase_103 AC 137 ms
57,688 KB
testcase_104 AC 148 ms
57,836 KB
testcase_105 AC 140 ms
57,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Kaibun {

	public static void main(String[] args) throws InterruptedException {
		Scanner s = new Scanner(System.in);
		long t = (long)Math.pow(10, 9) +1 , N = s.nextLong();
		s.close();
		int end = (int)(N/t);
		long count = 0, stock = 0;
		int keta = Integer.toString(end).length();
		
		if(keta == 1){
			count = end;
		}else{
			stock = 9;
			for(int i = 1;i < keta;i++){
				count += stock;
				if(i%2 == 0){
					stock *= 10;
				}
			}
			int k = (int)Math.pow(10, keta/2);
			count += ((end - (int)Math.pow(10,keta-1))/k+1);
			
			StringBuilder str = new StringBuilder(Integer.toString(end/k));
			String str2 = str.toString();
			if(keta%2 == 1){
				str.deleteCharAt(str.length()-1);
			}
			str2 = str2.concat(str.reverse().toString());
			if(Integer.parseInt(str2) > end){
				count--;
			}
		}
		System.out.println(count);
	}
}
0