結果

問題 No.432 占い(Easy)
ユーザー tentententen
提出日時 2020-11-04 12:02:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 5,092 ms
コンパイル使用メモリ 72,172 KB
実行使用メモリ 56,568 KB
最終ジャッジ日時 2023-09-29 15:45:47
合計ジャッジ時間 7,105 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
56,348 KB
testcase_01 AC 117 ms
56,144 KB
testcase_02 AC 117 ms
56,320 KB
testcase_03 AC 118 ms
55,776 KB
testcase_04 AC 118 ms
56,124 KB
testcase_05 AC 119 ms
56,256 KB
testcase_06 AC 129 ms
55,752 KB
testcase_07 AC 125 ms
55,512 KB
testcase_08 AC 124 ms
55,920 KB
testcase_09 AC 170 ms
56,428 KB
testcase_10 AC 132 ms
55,984 KB
testcase_11 AC 126 ms
55,496 KB
testcase_12 AC 132 ms
55,860 KB
testcase_13 AC 132 ms
56,448 KB
testcase_14 AC 123 ms
56,300 KB
testcase_15 AC 118 ms
56,044 KB
testcase_16 AC 119 ms
55,692 KB
testcase_17 AC 135 ms
56,544 KB
testcase_18 AC 153 ms
56,348 KB
testcase_19 AC 158 ms
55,956 KB
testcase_20 AC 134 ms
55,808 KB
testcase_21 AC 128 ms
55,752 KB
testcase_22 AC 127 ms
56,356 KB
testcase_23 AC 142 ms
56,064 KB
testcase_24 AC 164 ms
56,568 KB
testcase_25 AC 166 ms
56,148 KB
権限があれば一括ダウンロードができます

ソースコード

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