結果
問題 | No.933 おまわりさんこいつです |
ユーザー |
![]() |
提出日時 | 2019-11-29 22:19:45 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 830 ms / 2,000 ms |
コード長 | 1,020 bytes |
コンパイル時間 | 790 ms |
コンパイル使用メモリ | 110,244 KB |
実行使用メモリ | 40,064 KB |
最終ジャッジ日時 | 2024-11-20 23:29:01 |
合計ジャッジ時間 | 4,428 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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; prod = DigitSum(prod); } Console.WriteLine(DigitSum(prod)); } public static void Main() { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } }