結果

問題 No.656 ゴルフ
ユーザー matsuyoshi30matsuyoshi30
提出日時 2018-04-11 23:59:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 478 bytes
コンパイル時間 3,362 ms
コンパイル使用メモリ 71,004 KB
実行使用メモリ 56,372 KB
最終ジャッジ日時 2023-09-09 04:11:29
合計ジャッジ時間 4,277 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,600 KB
testcase_01 AC 118 ms
55,996 KB
testcase_02 AC 117 ms
56,372 KB
testcase_03 AC 117 ms
56,048 KB
testcase_04 AC 120 ms
55,840 KB
testcase_05 AC 116 ms
56,072 KB
testcase_06 AC 118 ms
56,112 KB
testcase_07 AC 120 ms
55,728 KB
testcase_08 AC 118 ms
55,732 KB
testcase_09 AC 117 ms
55,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int s = in.nextInt();

        int ans = 0;
        for(int i = 1; i <= 9; i++) {
            int temp = (int)((s % Math.pow(10, i)) / Math.pow(10, i-1));
            // System.out.println(temp);
            if(temp != 0)
                ans += temp;
            else
                ans += 10;
        }

        System.out.println(ans);
    }
}
0