結果

問題 No.1168 Digit Sum Sequence
ユーザー ks2m
提出日時 2020-08-14 21:23:22
言語 Java
(openjdk 23)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 2,158 ms
コンパイル使用メモリ 74,076 KB
実行使用メモリ 41,504 KB
最終ジャッジ日時 2024-10-10 12:44:20
合計ジャッジ時間 7,230 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		for (int i = 1; i < 100; i++) {
			int x = 0;
			while (n > 0) {
				x += n % 10;
				n /= 10;
			}
			n = x;
		}
		System.out.println(n);
	}
}
0