結果
| 問題 | No.10 +か×か |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-09 15:55:49 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,011 bytes |
| 記録 | |
| コンパイル時間 | 1,336 ms |
| コンパイル使用メモリ | 112,384 KB |
| 実行使用メモリ | 57,260 KB |
| 最終ジャッジ日時 | 2026-03-11 00:06:35 |
| 合計ジャッジ時間 | 13,584 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 WA * 3 TLE * 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.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 bool calc(int n, int a, int[] d, int l, int s, string o)
{
if (n == l)
{
if (s == a)
{
Console.WriteLine(o);
return true;
}
}
else if (s + d[l] > a)
{
return false;
}
else
{
if (calc(n, a, d, l + 1, s + d[l], o + "+"))
return true;
if (calc(n, a, d, l + 1, s * d[l], o + "*"))
return true;
}
return false;
}
}
}