結果

問題 No.222 引き算と足し算
ユーザー aketijyuuzouaketijyuuzou
提出日時 2024-10-10 23:39:51
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 90 ms / 1,000 ms
コード長 1,303 bytes
コンパイル時間 1,013 ms
コンパイル使用メモリ 113,784 KB
実行使用メモリ 30,676 KB
最終ジャッジ日時 2024-10-10 23:39:56
合計ジャッジ時間 4,758 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
28,332 KB
testcase_01 AC 90 ms
30,552 KB
testcase_02 AC 65 ms
30,360 KB
testcase_03 AC 66 ms
30,552 KB
testcase_04 AC 66 ms
28,644 KB
testcase_05 AC 65 ms
26,420 KB
testcase_06 AC 66 ms
28,724 KB
testcase_07 AC 67 ms
30,396 KB
testcase_08 AC 65 ms
28,512 KB
testcase_09 AC 64 ms
28,480 KB
testcase_10 AC 66 ms
28,644 KB
testcase_11 AC 65 ms
30,676 KB
testcase_12 AC 65 ms
30,608 KB
testcase_13 AC 67 ms
28,680 KB
testcase_14 AC 65 ms
28,248 KB
testcase_15 AC 66 ms
27,964 KB
testcase_16 AC 66 ms
30,548 KB
testcase_17 AC 67 ms
28,508 KB
testcase_18 AC 66 ms
28,384 KB
testcase_19 AC 66 ms
28,220 KB
testcase_20 AC 66 ms
30,396 KB
testcase_21 AC 64 ms
28,720 KB
testcase_22 AC 65 ms
28,384 KB
testcase_23 AC 65 ms
30,608 KB
testcase_24 AC 65 ms
30,424 KB
testcase_25 AC 64 ms
28,512 KB
testcase_26 AC 64 ms
28,592 KB
testcase_27 AC 65 ms
30,228 KB
testcase_28 AC 67 ms
28,768 KB
testcase_29 AC 66 ms
30,548 KB
testcase_30 AC 67 ms
30,556 KB
testcase_31 AC 66 ms
26,420 KB
testcase_32 AC 67 ms
30,604 KB
testcase_33 AC 67 ms
26,548 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.Generic;
using System.Text.RegularExpressions;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5+3");
            //2
            //入力は5+3ですが、5 - 3の演算の結果である2を出力します。
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("10-20");
            //30
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("-2+-3");
            //1
            //入力のx,yが符号を含む場合があります。
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        Match InsMatch = Regex.Match(InputList[0], @"([-+]?[0-9]+)([-+])([-+]?[0-9]+)$");
        int X = int.Parse(InsMatch.Groups[1].Value);
        string Ope = InsMatch.Groups[2].Value;
        int Y = int.Parse(InsMatch.Groups[3].Value);

        if (Ope == "+") Console.WriteLine(X - Y);
        else Console.WriteLine(X + Y);
    }
}

0