結果

問題 No.432 占い(Easy)
ユーザー Tsukasa_Type
提出日時 2018-02-24 03:42:48
言語 Java
(openjdk 23)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 2,175 ms
コンパイル使用メモリ 74,468 KB
実行使用メモリ 47,528 KB
最終ジャッジ日時 2024-10-11 06:04:22
合計ジャッジ時間 7,879 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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