結果
問題 | No.49 算数の宿題 |
ユーザー | swdamdr |
提出日時 | 2017-02-15 13:47:00 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 58 ms / 5,000 ms |
コード長 | 690 bytes |
コンパイル時間 | 2,087 ms |
コンパイル使用メモリ | 106,556 KB |
実行使用メモリ | 22,776 KB |
最終ジャッジ日時 | 2023-08-24 17:36:02 |
合計ジャッジ時間 | 3,466 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 57 ms
20,696 KB |
testcase_01 | AC | 57 ms
20,696 KB |
testcase_02 | AC | 57 ms
22,760 KB |
testcase_03 | AC | 57 ms
20,816 KB |
testcase_04 | AC | 57 ms
20,876 KB |
testcase_05 | AC | 57 ms
22,776 KB |
testcase_06 | AC | 57 ms
20,756 KB |
testcase_07 | AC | 56 ms
20,696 KB |
testcase_08 | AC | 57 ms
20,728 KB |
testcase_09 | AC | 58 ms
22,760 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.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { string s = Console.ReadLine(); string[] su = s.Split('*', '+'); int ans = int.Parse(su[0]); for (int i = 0; i < su.Length - 1; i++) { s = s.Remove(0, su[i].Length); if (s[0] == '*') { ans += int.Parse(su[i + 1]); s = s.TrimStart('*'); } else { ans *= int.Parse(su[i + 1]); s = s.TrimStart('+'); } } Console.WriteLine(ans); Console.ReadLine(); } }