結果
問題 | No.852 連続部分文字列 |
ユーザー | tenten |
提出日時 | 2023-11-16 09:03:52 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 271 ms / 3,153 ms |
コード長 | 2,057 bytes |
コンパイル時間 | 2,786 ms |
コンパイル使用メモリ | 90,792 KB |
実行使用メモリ | 44,748 KB |
最終ジャッジ日時 | 2024-09-26 05:02:38 |
合計ジャッジ時間 | 9,962 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 53 ms
37,476 KB |
testcase_01 | AC | 53 ms
37,328 KB |
testcase_02 | AC | 53 ms
37,388 KB |
testcase_03 | AC | 53 ms
37,308 KB |
testcase_04 | AC | 53 ms
37,612 KB |
testcase_05 | AC | 52 ms
37,348 KB |
testcase_06 | AC | 52 ms
37,372 KB |
testcase_07 | AC | 53 ms
37,120 KB |
testcase_08 | AC | 53 ms
37,336 KB |
testcase_09 | AC | 54 ms
37,376 KB |
testcase_10 | AC | 52 ms
37,256 KB |
testcase_11 | AC | 52 ms
37,252 KB |
testcase_12 | AC | 52 ms
37,372 KB |
testcase_13 | AC | 66 ms
37,896 KB |
testcase_14 | AC | 58 ms
36,972 KB |
testcase_15 | AC | 75 ms
38,368 KB |
testcase_16 | AC | 66 ms
37,856 KB |
testcase_17 | AC | 71 ms
38,452 KB |
testcase_18 | AC | 74 ms
38,144 KB |
testcase_19 | AC | 54 ms
37,212 KB |
testcase_20 | AC | 75 ms
38,104 KB |
testcase_21 | AC | 75 ms
38,388 KB |
testcase_22 | AC | 63 ms
37,964 KB |
testcase_23 | AC | 72 ms
38,500 KB |
testcase_24 | AC | 64 ms
37,976 KB |
testcase_25 | AC | 75 ms
38,552 KB |
testcase_26 | AC | 74 ms
38,752 KB |
testcase_27 | AC | 68 ms
38,364 KB |
testcase_28 | AC | 72 ms
38,360 KB |
testcase_29 | AC | 74 ms
38,496 KB |
testcase_30 | AC | 57 ms
37,524 KB |
testcase_31 | AC | 74 ms
38,408 KB |
testcase_32 | AC | 76 ms
38,436 KB |
testcase_33 | AC | 271 ms
44,716 KB |
testcase_34 | AC | 261 ms
44,748 KB |
testcase_35 | AC | 255 ms
44,496 KB |
testcase_36 | AC | 263 ms
44,500 KB |
testcase_37 | AC | 262 ms
44,480 KB |
testcase_38 | AC | 267 ms
44,444 KB |
testcase_39 | AC | 262 ms
44,392 KB |
testcase_40 | AC | 263 ms
44,472 KB |
testcase_41 | AC | 266 ms
44,316 KB |
testcase_42 | AC | 263 ms
44,720 KB |
testcase_43 | AC | 261 ms
44,528 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); char[] inputs = sc.next().toCharArray(); int length = inputs.length; double total = 26 * (length + 1L) * length / 2; for (char c = 'a'; c <= 'z'; c = (char)(c + 1)) { int count = 0; for (char x : inputs) { if (c == x) { total -= (count + 1L) * count / 2; count = 0; } else { count++; } } total -= (count + 1L) * count / 2; } total /= (length + 1L) * length / 2; System.out.println(new java.math.BigDecimal(total).toPlainString()); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }