結果

問題 No.432 占い(Easy)
ユーザー tenten
提出日時 2020-11-04 12:02:43
言語 Java
(openjdk 23)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 2,112 ms
コンパイル使用メモリ 74,184 KB
実行使用メモリ 42,136 KB
最終ジャッジ日時 2024-07-22 09:55:22
合計ジャッジ時間 7,066 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		while (0 < t--) {
		    char[] tmp = sc.next().toCharArray();
		    int n = tmp.length;
		    int[] arr = new int[n];
    		for (int i = 0; i < n; i++) {
    		    arr[i] = tmp[i] - '0';
    		}
    		for (int i = n - 1; i >= 0; i--) {
    		    for (int j = 0; j < i; j++) {
    		        arr[j] = calc(arr[j], arr[j + 1]);
    		    }
    		}
    		sb.append(arr[0]).append("\n");
		}
		System.out.print(sb);
	}
	
	static int calc(int x, int y) {
	    int ans = x + y;
	    return ans / 10 + ans % 10;
	}
}
0