結果

問題 No.933 おまわりさんこいつです
ユーザー tomomo2b2
提出日時 2019-11-29 22:18:41
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 985 bytes
コンパイル時間 885 ms
コンパイル使用メモリ 115,352 KB
実行使用メモリ 75,384 KB
最終ジャッジ日時 2024-11-20 23:28:36
合計ジャッジ時間 19,398 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 TLE * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Numerics;

class MyClass
{
    public static int DigitSum(BigInteger n)
    {
        if (n < 10)
        {
            return (int)n;
        }
        else
        {
            BigInteger dsum = 0;
            while (n > 0)
            {
                dsum += n % 10;
                n /= 10;
            }
            return DigitSum(dsum);
        }
    }

    public static void Solve()
    {
        var N = int.Parse(Console.ReadLine());
        var P = Console.ReadLine().Split().Select(BigInteger.Parse).ToArray();
        BigInteger prod = 1;
        foreach (var item in P)
        {
            prod *= item;
        }
        Console.WriteLine(DigitSum(prod));
    }

    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
0