結果

問題 No.432 占い(Easy)
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-24 03:42:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 265 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 2,446 ms
コンパイル使用メモリ 74,276 KB
実行使用メモリ 47,404 KB
最終ジャッジ日時 2024-04-19 13:39:45
合計ジャッジ時間 7,985 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
40,124 KB
testcase_01 AC 136 ms
41,088 KB
testcase_02 AC 109 ms
39,788 KB
testcase_03 AC 132 ms
41,680 KB
testcase_04 AC 142 ms
41,928 KB
testcase_05 AC 130 ms
41,464 KB
testcase_06 AC 148 ms
41,120 KB
testcase_07 AC 153 ms
41,768 KB
testcase_08 AC 128 ms
41,392 KB
testcase_09 AC 211 ms
42,428 KB
testcase_10 AC 178 ms
42,020 KB
testcase_11 AC 193 ms
44,912 KB
testcase_12 AC 265 ms
47,292 KB
testcase_13 AC 259 ms
47,324 KB
testcase_14 AC 186 ms
44,912 KB
testcase_15 AC 137 ms
41,256 KB
testcase_16 AC 138 ms
41,304 KB
testcase_17 AC 260 ms
47,404 KB
testcase_18 AC 216 ms
46,788 KB
testcase_19 AC 219 ms
46,140 KB
testcase_20 AC 183 ms
45,668 KB
testcase_21 AC 191 ms
45,532 KB
testcase_22 AC 177 ms
42,200 KB
testcase_23 AC 188 ms
41,800 KB
testcase_24 AC 213 ms
42,416 KB
testcase_25 AC 218 ms
42,920 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();
		String s;
		String a;
		StringBuilder sb = new StringBuilder();
		
		for (int i=0; i<n; i++) {
			s = sc.next();
			a = s;
			
			while (true) { //1桁になるまでループを回す
				if (a.length()==1) {break;}
				sb.setLength(0);
				
				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));
					sb.append(i1/10+i1%10);
					
				}
				
				a = sb.toString();
			}
			
			out.println(a);
		}
	}
}
0