結果

問題 No.434 占い
ユーザー htensaihtensai
提出日時 2020-01-08 21:14:21
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 970 bytes
コンパイル時間 2,128 ms
コンパイル使用メモリ 74,824 KB
実行使用メモリ 52,452 KB
最終ジャッジ日時 2023-08-15 00:45:37
合計ジャッジ時間 8,698 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,312 KB
testcase_01 AC 42 ms
49,172 KB
testcase_02 AC 41 ms
49,176 KB
testcase_03 AC 43 ms
49,312 KB
testcase_04 AC 43 ms
49,232 KB
testcase_05 AC 43 ms
49,216 KB
testcase_06 AC 50 ms
49,196 KB
testcase_07 AC 44 ms
49,048 KB
testcase_08 AC 158 ms
51,892 KB
testcase_09 AC 101 ms
52,376 KB
testcase_10 AC 70 ms
51,740 KB
testcase_11 AC 64 ms
51,492 KB
testcase_12 AC 89 ms
51,684 KB
testcase_13 AC 159 ms
51,640 KB
testcase_14 AC 102 ms
52,452 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(calc(br.readLine())).append("\n");
        }
        System.out.print(sb);
    }
    
    static int calc(String s) {
        char[] arr = s.toCharArray();
        int n = arr.length;
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = arr[i] - '0';
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = 0; j < n - 1 - i; j++) {
                nums[j] = cInt(nums[j], nums[j + 1]);
            }
        }
        return nums[0];
    }
    
    static int cInt(int x, int y) {
        int ans = x + y;
        return ans % 10 + ans / 10;
    }
}
0