結果

問題 No.10 +か×か
ユーザー HimatsubushinHimatsubushin
提出日時 2022-02-09 15:49:27
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 785 bytes
コンパイル時間 3,178 ms
コンパイル使用メモリ 104,080 KB
実行使用メモリ 29,972 KB
最終ジャッジ日時 2023-09-07 00:59:05
合計ジャッジ時間 9,669 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
21,748 KB
testcase_01 WA -
testcase_02 AC 59 ms
21,900 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 No._10
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int a = int.Parse(Console.ReadLine());
            int[] d = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            calc(n, a, d, 1, d[0], "");
        }

        static void calc(int n, int a, int[] d, int l, int s, string o)
        {
            if (n == l)
            {
                if (s == a)
                {
                    Console.WriteLine(o);
                }
            }
            else
            {
                calc(n, a, d, l + 1, s + d[l], o + "+");
                calc(n, a, d, l + 1, s * d[l], o + "*");
            }
        }
    }
}
0