結果

問題 No.1168 Digit Sum Sequence
ユーザー tentententen
提出日時 2020-08-17 18:21:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 437 bytes
コンパイル時間 2,188 ms
コンパイル使用メモリ 74,172 KB
実行使用メモリ 41,600 KB
最終ジャッジ日時 2024-04-19 19:00:52
合計ジャッジ時間 6,327 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
41,292 KB
testcase_01 AC 106 ms
40,868 KB
testcase_02 AC 123 ms
40,968 KB
testcase_03 AC 118 ms
41,488 KB
testcase_04 AC 115 ms
41,060 KB
testcase_05 AC 115 ms
41,380 KB
testcase_06 AC 111 ms
41,060 KB
testcase_07 AC 111 ms
40,152 KB
testcase_08 AC 114 ms
41,028 KB
testcase_09 AC 117 ms
41,600 KB
testcase_10 AC 116 ms
41,424 KB
testcase_11 AC 119 ms
41,084 KB
testcase_12 AC 120 ms
41,224 KB
testcase_13 AC 119 ms
41,092 KB
testcase_14 AC 107 ms
41,384 KB
testcase_15 AC 117 ms
41,208 KB
testcase_16 AC 117 ms
41,068 KB
testcase_17 AC 120 ms
41,180 KB
testcase_18 AC 121 ms
41,388 KB
testcase_19 AC 118 ms
41,552 KB
testcase_20 AC 114 ms
41,312 KB
testcase_21 AC 107 ms
41,308 KB
testcase_22 AC 118 ms
41,000 KB
testcase_23 AC 104 ms
40,904 KB
testcase_24 AC 117 ms
41,572 KB
testcase_25 AC 126 ms
41,228 KB
testcase_26 AC 115 ms
40,912 KB
testcase_27 AC 117 ms
41,304 KB
testcase_28 AC 112 ms
41,428 KB
testcase_29 AC 118 ms
41,224 KB
testcase_30 AC 120 ms
41,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 1; i < 100; i++) {
            n = calc(n);
        }
        System.out.println(n);
    }
    
    static int calc(int x) {
        int ans = 0;
        while (x > 0) {
            ans += x % 10;
            x /= 10;
        }
        return ans;
    }
}
0