結果

問題 No.933 おまわりさんこいつです
ユーザー tomomo2b2
提出日時 2019-11-29 22:00:26
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 970 bytes
コンパイル時間 3,157 ms
コンパイル使用メモリ 105,472 KB
実行使用メモリ 37,376 KB
最終ジャッジ日時 2024-11-20 22:14:33
合計ジャッジ時間 2,693 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

class MyClass
{
    public static long DigitSum(long n)
    {
        if (n < 10)
        {
            return n;
        }
        else
        {
            var dsum = 0L;
            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(long.Parse).ToArray();
        var Q = P.Select(DigitSum);
        var prod = 1L;
        foreach (var item in Q)
        {
            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