結果

問題 No.933 おまわりさんこいつです
ユーザー tomomo2b2tomomo2b2
提出日時 2019-11-29 22:18:41
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 985 bytes
コンパイル時間 884 ms
コンパイル使用メモリ 115,248 KB
実行使用メモリ 61,320 KB
最終ジャッジ日時 2024-05-01 00:33:22
合計ジャッジ時間 6,344 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
33,104 KB
testcase_01 AC 36 ms
25,836 KB
testcase_02 AC 37 ms
28,084 KB
testcase_03 AC 36 ms
25,900 KB
testcase_04 AC 38 ms
28,080 KB
testcase_05 AC 38 ms
26,160 KB
testcase_06 AC 37 ms
25,836 KB
testcase_07 AC 37 ms
26,152 KB
testcase_08 AC 37 ms
27,880 KB
testcase_09 AC 38 ms
26,032 KB
testcase_10 AC 37 ms
25,776 KB
testcase_11 AC 45 ms
24,244 KB
testcase_12 AC 57 ms
30,492 KB
testcase_13 AC 377 ms
30,496 KB
testcase_14 AC 772 ms
56,224 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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