結果
| 問題 |
No.49 算数の宿題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-15 13:47:00 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 5,000 ms |
| コード長 | 690 bytes |
| コンパイル時間 | 1,100 ms |
| コンパイル使用メモリ | 111,688 KB |
| 実行使用メモリ | 25,884 KB |
| 最終ジャッジ日時 | 2024-12-23 01:55:18 |
| 合計ジャッジ時間 | 1,702 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
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();
}
}