結果

問題 No.49 算数の宿題
ユーザー mbanmban
提出日時 2016-12-28 16:54:51
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 1,356 bytes
コンパイル時間 4,809 ms
コンパイル使用メモリ 100,776 KB
実行使用メモリ 22,768 KB
最終ジャッジ日時 2023-08-24 17:35:33
合計ジャッジ時間 3,260 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
22,760 KB
testcase_01 AC 54 ms
20,752 KB
testcase_02 AC 54 ms
22,768 KB
testcase_03 AC 54 ms
20,664 KB
testcase_04 AC 54 ms
20,708 KB
testcase_05 AC 54 ms
20,752 KB
testcase_06 AC 54 ms
20,660 KB
testcase_07 AC 54 ms
20,632 KB
testcase_08 AC 54 ms
20,664 KB
testcase_09 AC 55 ms
22,768 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{

    static void Main()
    {
        string S = Console.ReadLine();
        int ans = 0;
        Ty T = Ty.puls;
        string SS = "";
        for(int i = 0; i < S.Length; i++)
        {
            if (S[i] == '*')
            {
                if (T == Ty.puls)
                {
                    ans += int.Parse(SS);

                }
                else
                {
                    ans *= int.Parse(SS);
                }
                T = Ty.puls;
                SS = "";
            }
            else if (S[i] == '+')
            {
                if (T == Ty.puls)
                {
                    ans += int.Parse(SS);

                }
                else
                {
                    ans *= int.Parse(SS);
                }
                SS = "";
                T = Ty.kakeru;
            }
            else
            {
                SS += S[i];
            }
        }
        if (T == Ty.puls)
        {
            ans += int.Parse(SS);

        }
        else
        {
            ans *= int.Parse(SS);
        }
        Console.WriteLine(ans);
    }
}
public enum Ty
{
    puls, kakeru
}

0