結果
問題 | No.49 算数の宿題 |
ユーザー | bluemegane |
提出日時 | 2018-10-08 09:41:34 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 62 ms / 5,000 ms |
コード長 | 730 bytes |
コンパイル時間 | 2,466 ms |
コンパイル使用メモリ | 103,684 KB |
実行使用メモリ | 23,628 KB |
最終ジャッジ日時 | 2023-08-24 17:40:21 |
合計ジャッジ時間 | 3,831 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 60 ms
21,500 KB |
testcase_01 | AC | 61 ms
23,524 KB |
testcase_02 | AC | 62 ms
23,588 KB |
testcase_03 | AC | 61 ms
21,572 KB |
testcase_04 | AC | 61 ms
21,428 KB |
testcase_05 | AC | 61 ms
23,496 KB |
testcase_06 | AC | 61 ms
23,628 KB |
testcase_07 | AC | 61 ms
23,568 KB |
testcase_08 | AC | 61 ms
21,664 KB |
testcase_09 | AC | 61 ms
21,436 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Collections.Generic; using System.Linq; using System; public class Hello { public static void Main() { var s = Console.ReadLine().Trim(); string[] line = s.Split('*', '+'); var a = Array.ConvertAll(line, int.Parse); var b = new List<char>(); foreach (var x in s) if (x == '+') b.Add('m'); else if (x == '*') b.Add('p'); int ans; if (b[0] == 'm') ans = a[0] * a[1]; else ans = a[0] + a[1]; if (b.Count() == 1) goto end; for (int i = 2; i < a.Length; i++) { if (b[i - 1] == 'm') ans *= a[i]; else ans += a[i]; } end:; Console.WriteLine(ans); } }