結果

問題 No.1168 Digit Sum Sequence
ユーザー ks2mks2m
提出日時 2020-08-14 21:23:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 2,967 ms
コンパイル使用メモリ 74,276 KB
実行使用メモリ 54,548 KB
最終ジャッジ日時 2024-04-18 19:22:33
合計ジャッジ時間 7,233 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
54,108 KB
testcase_01 AC 129 ms
54,172 KB
testcase_02 AC 126 ms
54,220 KB
testcase_03 AC 124 ms
52,572 KB
testcase_04 AC 125 ms
54,484 KB
testcase_05 AC 128 ms
54,040 KB
testcase_06 AC 111 ms
53,008 KB
testcase_07 AC 131 ms
54,300 KB
testcase_08 AC 124 ms
54,204 KB
testcase_09 AC 127 ms
54,124 KB
testcase_10 AC 127 ms
54,144 KB
testcase_11 AC 129 ms
54,144 KB
testcase_12 AC 126 ms
54,044 KB
testcase_13 AC 125 ms
54,100 KB
testcase_14 AC 128 ms
54,060 KB
testcase_15 AC 124 ms
54,108 KB
testcase_16 AC 128 ms
54,212 KB
testcase_17 AC 132 ms
54,012 KB
testcase_18 AC 129 ms
53,992 KB
testcase_19 AC 126 ms
54,148 KB
testcase_20 AC 127 ms
54,208 KB
testcase_21 AC 126 ms
54,064 KB
testcase_22 AC 124 ms
54,028 KB
testcase_23 AC 124 ms
54,084 KB
testcase_24 AC 126 ms
53,760 KB
testcase_25 AC 130 ms
54,132 KB
testcase_26 AC 127 ms
54,248 KB
testcase_27 AC 129 ms
54,548 KB
testcase_28 AC 115 ms
53,008 KB
testcase_29 AC 130 ms
54,100 KB
testcase_30 AC 125 ms
54,388 KB
権限があれば一括ダウンロードができます

ソースコード

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