結果
問題 | No.49 算数の宿題 |
ユーザー | nanophoto12 |
提出日時 | 2014-11-05 01:38:14 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 60 ms / 5,000 ms |
コード長 | 1,173 bytes |
コンパイル時間 | 3,971 ms |
コンパイル使用メモリ | 102,836 KB |
実行使用メモリ | 23,904 KB |
最終ジャッジ日時 | 2023-08-24 17:23:39 |
合計ジャッジ時間 | 5,296 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 58 ms
21,784 KB |
testcase_01 | AC | 58 ms
23,888 KB |
testcase_02 | AC | 58 ms
23,904 KB |
testcase_03 | AC | 57 ms
19,804 KB |
testcase_04 | AC | 58 ms
21,768 KB |
testcase_05 | AC | 58 ms
21,736 KB |
testcase_06 | AC | 58 ms
21,884 KB |
testcase_07 | AC | 59 ms
21,680 KB |
testcase_08 | AC | 60 ms
21,764 KB |
testcase_09 | AC | 58 ms
23,844 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; internal class Program { public static void Main(string[] args) { var s = Console.ReadLine(); List<string> parsing = new List<string>(); List<char> token = new List<char>(); int prev = 0; for (int i = 0; i < s.Length; i++) { if (s[i] == '*' || s[i] == '+') { parsing.Add(s.Substring(prev, i - prev)); token.Add(s[i]); prev = i + 1; } } if (token.Count == 0) { Console.WriteLine(s); return; } parsing.Add(s.Substring(prev, s.Length - prev)); int[] nums = parsing.Select(int.Parse).ToArray(); var current = nums[0]; for (int i = 1; i < nums.Length; i++) { if (token[i - 1] == '*') { current = current + nums[i]; } else { current = current * nums[i]; } } Console.WriteLine(current); } }