結果

問題 No.432 占い(Easy)
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-24 03:38:56
言語 Java19
(openjdk 21)
結果
AC  
実行時間 311 ms / 2,000 ms
コード長 616 bytes
コンパイル時間 2,204 ms
コンパイル使用メモリ 74,064 KB
実行使用メモリ 60,932 KB
最終ジャッジ日時 2023-08-01 14:21:49
合計ジャッジ時間 9,019 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 152 ms
56,540 KB
testcase_01 AC 119 ms
56,116 KB
testcase_02 AC 154 ms
56,704 KB
testcase_03 AC 164 ms
56,892 KB
testcase_04 AC 175 ms
59,068 KB
testcase_05 AC 153 ms
57,028 KB
testcase_06 AC 130 ms
55,704 KB
testcase_07 AC 178 ms
58,900 KB
testcase_08 AC 156 ms
57,044 KB
testcase_09 AC 198 ms
56,756 KB
testcase_10 AC 189 ms
57,452 KB
testcase_11 AC 215 ms
59,332 KB
testcase_12 AC 308 ms
60,396 KB
testcase_13 AC 311 ms
60,640 KB
testcase_14 AC 214 ms
59,060 KB
testcase_15 AC 160 ms
56,880 KB
testcase_16 AC 153 ms
56,544 KB
testcase_17 AC 310 ms
60,932 KB
testcase_18 AC 283 ms
60,684 KB
testcase_19 AC 287 ms
60,900 KB
testcase_20 AC 222 ms
59,200 KB
testcase_21 AC 231 ms
59,808 KB
testcase_22 AC 194 ms
57,032 KB
testcase_23 AC 207 ms
56,780 KB
testcase_24 AC 208 ms
57,416 KB
testcase_25 AC 208 ms
56,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		
		for (int i=0; i<n; i++) {
			String s = sc.next();
			String a = s;
			
			while (true) { //1桁になるまでループを回す
				if (a.length()==1) {break;}
				String b = "";
				
				for (int j=0; j<a.length()-1; j++) {
					
					int i1 = Integer.parseInt(a.substring(j,j+1));
					i1 += Integer.parseInt(a.substring(j+1,j+2));
					b += i1/10 + i1%10;
					
				}
				
				a = b;
			}
			
			out.println(a);
		}
	}
}
0