Submission #3417262


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = Console.ReadLine().Trim();
            List<int> lstInp = new List<int>();
            for (int i = 0; i < sS.Length; i++)
            {
                lstInp.Add(int.Parse(sS.Substring(i, 1)));
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "";
            if (lstInp[0] + lstInp[1] + lstInp[2] + lstInp[3] == 7) { sOut = lstInp[0].ToString() + "+" + lstInp[1].ToString() + "+" + lstInp[2].ToString() + "+" + lstInp[3].ToString() + "=7"; }
            if (lstInp[0] + lstInp[1] + lstInp[2] - lstInp[3] == 7) { sOut = lstInp[0].ToString() + "+" + lstInp[1].ToString() + "+" + lstInp[2].ToString() + "-" + lstInp[3].ToString() + "=7"; }
            if (lstInp[0] + lstInp[1] - lstInp[2] + lstInp[3] == 7) { sOut = lstInp[0].ToString() + "+" + lstInp[1].ToString() + "-" + lstInp[2].ToString() + "+" + lstInp[3].ToString() + "=7"; }
            if (lstInp[0] + lstInp[1] - lstInp[2] - lstInp[3] == 7) { sOut = lstInp[0].ToString() + "+" + lstInp[1].ToString() + "-" + lstInp[2].ToString() + "-" + lstInp[3].ToString() + "=7"; }
            if (lstInp[0] - lstInp[1] + lstInp[2] + lstInp[3] == 7) { sOut = lstInp[0].ToString() + "-" + lstInp[1].ToString() + "+" + lstInp[2].ToString() + "+" + lstInp[3].ToString() + "=7"; }
            if (lstInp[0] - lstInp[1] + lstInp[2] - lstInp[3] == 7) { sOut = lstInp[0].ToString() + "-" + lstInp[1].ToString() + "+" + lstInp[2].ToString() + "-" + lstInp[3].ToString() + "=7"; }
            if (lstInp[0] - lstInp[1] - lstInp[2] + lstInp[3] == 7) { sOut = lstInp[0].ToString() + "-" + lstInp[1].ToString() + "-" + lstInp[2].ToString() + "+" + lstInp[3].ToString() + "=7"; }
            if (lstInp[0] - lstInp[1] - lstInp[2] - lstInp[3] == 7) { sOut = lstInp[0].ToString() + "-" + lstInp[1].ToString() + "-" + lstInp[2].ToString() + "-" + lstInp[3].ToString() + "=7"; }

            // 出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください...");
            Console.ReadKey();
#endif
    }
}

Submission Info

Submission Time
Task C - Train Ticket
User starlightsheep
Language C# (Mono 4.6.2.0)
Score 300
Code Size 2519 Byte
Status AC
Exec Time 24 ms
Memory 13908 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 19
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01.txt AC 23 ms 9812 KB
02.txt AC 23 ms 11860 KB
03.txt AC 24 ms 13908 KB
04.txt AC 23 ms 9812 KB
05.txt AC 24 ms 13908 KB
06.txt AC 23 ms 9812 KB
07.txt AC 23 ms 11860 KB
08.txt AC 24 ms 13908 KB
09.txt AC 23 ms 9812 KB
10.txt AC 23 ms 9812 KB
11.txt AC 23 ms 11860 KB
12.txt AC 23 ms 13908 KB
13.txt AC 24 ms 11860 KB
14.txt AC 24 ms 13908 KB
15.txt AC 24 ms 11860 KB
16.txt AC 23 ms 11860 KB
sample_01.txt AC 23 ms 11860 KB
sample_02.txt AC 23 ms 9812 KB
sample_03.txt AC 23 ms 11860 KB