結果

問題 No.434 占い
ユーザー htensai
提出日時 2020-01-08 21:14:21
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 970 bytes
コンパイル時間 2,842 ms
コンパイル使用メモリ 77,192 KB
実行使用メモリ 83,196 KB
最終ジャッジ日時 2024-11-23 03:08:13
合計ジャッジ時間 39,546 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21 TLE * 6
権限があれば一括ダウンロードができます

ソースコード

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