結果
| 問題 | No.708 (+ー)の式 | 
| コンテスト | |
| ユーザー |  No | 
| 提出日時 | 2018-07-09 23:12:36 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,207 bytes | 
| コンパイル時間 | 849 ms | 
| コンパイル使用メモリ | 111,472 KB | 
| 実行使用メモリ | 30,800 KB | 
| 最終ジャッジ日時 | 2024-07-18 00:13:18 | 
| 合計ジャッジ時間 | 2,356 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 WA * 2 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Text.RegularExpressions;
namespace y
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            int a = 0;
            while (!int.TryParse(s, out a))
            {
                s = Ca(s);
            }
            Console.WriteLine(a);
        }
        static string Ca(string s)
        {
            string a = Regex.Match(s, @"\(.*?\)").Value;
            if (a.Length == 0) a = s;
            int r = 0;
            bool isMinus = false;
            for (int j = 0; j < a.Length; j++)
            {
                if (a[j] == '-')
                {
                    isMinus = true;
                    continue;
                }
                if (a[j] >= '0' && a[j] <= '9')
                {
                    if (!isMinus)
                    {
                        r += int.Parse(a[j].ToString());
                    }
                    else
                    {
                        r -= int.Parse(a[j].ToString());
                        isMinus = false;
                    }
                }
            }
            return s.Replace(a, r.ToString());
        }
    }
}
            
            
            
        