結果

問題 No.297 カードの数式
ユーザー r_nokor_noko
提出日時 2015-11-08 19:08:11
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,589 bytes
コンパイル時間 2,244 ms
コンパイル使用メモリ 109,044 KB
実行使用メモリ 26,368 KB
最終ジャッジ日時 2023-10-11 15:20:52
合計ジャッジ時間 5,328 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 RE -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 RE -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;

namespace contest
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            if (input.Length > 10)
                input[0] = input[0][2].ToString();
            else
                input[0] = input[0][1].ToString();

            var p = input.Where(x => x == "+").Select(x => x);
            var m = input.Where(x => x == "-").Select(x => x);
            var pm = p.Concat(m);
            var n = input.Where(x => !pm.Contains(x)).OrderByDescending(x => x).Select(x => x);
            var nn = input.Where(x => !pm.Contains(x)).OrderBy(x => x).Select(x => x);

            var g = n.Take(n.Count() - pm.Count()).Select(x => x);
            double b = 0;
            string ss = "";
            double a = 0;

            for (int i = 0; i < g.Count(); i++)
                ss += g.ToArray()[i];
            b = a = double.Parse(ss);

            int cnt = g.Count();
            int ncnt = cnt;

            for (int i = 0; i < p.Count(); i++)
            {
                a += double.Parse(n.Skip(cnt++).Select(x => x).ToArray()[0]);
                b += double.Parse(n.Skip(ncnt++).Select(x => x).ToArray()[0]);

            }

            for (int i = 0; i < m.Count(); i++)
            {
                a -= double.Parse(n.Skip(cnt++).Select(x => x).ToArray()[0]);
                b = double.Parse(n.Skip(ncnt++).Select(x => x).ToArray()[0]) - b;
            }


            Console.WriteLine(a + " " + b);
            Console.ReadLine();
        }
    }
}
0