結果

問題 No.2607 Add One Digit
ユーザー ks2mks2m
提出日時 2024-01-19 21:50:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 189 ms / 1,000 ms
コード長 527 bytes
コンパイル時間 2,315 ms
コンパイル使用メモリ 77,688 KB
実行使用メモリ 58,860 KB
最終ジャッジ日時 2024-01-19 21:50:34
合計ジャッジ時間 6,862 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 170 ms
58,852 KB
testcase_01 AC 174 ms
58,740 KB
testcase_02 AC 175 ms
58,860 KB
testcase_03 AC 173 ms
58,840 KB
testcase_04 AC 172 ms
58,744 KB
testcase_05 AC 180 ms
58,844 KB
testcase_06 AC 180 ms
58,848 KB
testcase_07 AC 173 ms
58,840 KB
testcase_08 AC 174 ms
58,748 KB
testcase_09 AC 172 ms
58,852 KB
testcase_10 AC 172 ms
58,848 KB
testcase_11 AC 181 ms
58,840 KB
testcase_12 AC 179 ms
58,848 KB
testcase_13 AC 176 ms
58,852 KB
testcase_14 AC 174 ms
58,848 KB
testcase_15 AC 175 ms
58,856 KB
testcase_16 AC 189 ms
58,828 KB
testcase_17 AC 178 ms
58,836 KB
testcase_18 AC 175 ms
58,844 KB
testcase_19 AC 179 ms
58,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		Set<Long> set = new HashSet<>();
		for (int i = 0; i <= s.length(); i++) {
			for (int j = 0; j <= 9; j++) {
				String t = s.substring(0, i) + j + s.substring(i);
				long v = Long.parseLong(t);
				set.add(v);
			}
		}
		set.remove(Long.parseLong(s));
		System.out.println(set.size());
	}
}
0