結果

問題 No.1168 Digit Sum Sequence
ユーザー xRS43BofaUEZ5gc
提出日時 2021-03-04 09:24:13
言語 Java
(openjdk 23)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 2,929 ms
コンパイル使用メモリ 74,432 KB
実行使用メモリ 54,328 KB
最終ジャッジ日時 2024-10-04 12:40:15
合計ジャッジ時間 7,713 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class HelloWorld {

	    public static void main(String[] args) throws Exception {

	    	Scanner sc = new Scanner(System.in);
	    	int a0 = sc.nextInt();
	    	for (int i = 0; i < 100; i++) {
	    		a0 = nextA(a0);
	    	}

	    	System.out.println(nextA(a0));

	    	}

	    static int nextA(int a) {
	    	int next_a = 0;
	    	while (a > 0) {
	    		next_a += a % 10;
	    		a /= 10;
	    	}

	    	return next_a;
	    }

}
0