結果

問題 No.933 おまわりさんこいつです
ユーザー htensai
提出日時 2019-12-09 21:44:31
言語 Java
(openjdk 23)
結果
AC  
実行時間 583 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 2,100 ms
コンパイル使用メモリ 74,064 KB
実行使用メモリ 51,460 KB
最終ジャッジ日時 2024-06-23 06:24:35
合計ジャッジ時間 8,293 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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