結果
問題 | No.49 算数の宿題 |
ユーザー |
![]() |
提出日時 | 2018-10-08 09:41:34 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 27 ms / 5,000 ms |
コード長 | 730 bytes |
コンパイル時間 | 892 ms |
コンパイル使用メモリ | 105,728 KB |
実行使用メモリ | 18,560 KB |
最終ジャッジ日時 | 2024-12-23 02:00:26 |
合計ジャッジ時間 | 1,610 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
コンパイルメッセージ
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);}}