結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
YoshiRyu
|
| 提出日時 | 2016-11-03 03:07:47 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,418 bytes |
| コンパイル時間 | 1,200 ms |
| コンパイル使用メモリ | 116,016 KB |
| 実行使用メモリ | 50,784 KB |
| 最終ジャッジ日時 | 2024-11-25 01:57:05 |
| 合計ジャッジ時間 | 14,118 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 WA * 1 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.Collections.Generic;
using System.IO;
using System.Linq;
public class YukiCoder
{
public static void Solve()
{
var N = MyConsole.Int();
var Total = MyConsole.Int();
var A = MyConsole.IntSplit();
bool found = false;
Func<char[],int,int, bool> act = null;
act = ( Formula, Base, Index ) =>
{
if (found) return true;
if (Base < Total && Index < N)
{
Formula[Index - 1] = '+';
if (act( Formula, Base + A[Index], Index + 1 )) return true;
Formula[Index - 1] = '*';
if (act( Formula, Base * A[Index], Index + 1 )) return true;
}
else if (Base == Total && Index == N)
{
MyConsole.wLine( new string( System.Linq.Enumerable.ToArray( Formula ) ) );
found = true;
}
return false;
};
// 演算の実行
act( new char[N - 1], A[0], 1 );
}
public static void Main()
{
MyConsole.Read(); Solve(); MyConsole.Finish();
}
}
public static class MyConsole
{
private static List<string> ReadedLine = new List<string>();
private static char[] buf = new char[1024];
private static int i;
public static void Read()
{
string sr = Console.In.ReadToEnd();
ReadedLine = sr.Split( new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries ).ToList();
Console.SetOut( new StreamWriter( Console.OpenStandardOutput() ) { AutoFlush = false } );
}
public static string String() { return ReadedLine[i++]; }
public static string[] StringSplit() { return ReadedLine[i++].Split( new[] { ' ' } ); }
public static int Int() { return int.Parse( ReadedLine[i++] ); }
public static int[] IntSplit()
{
string[] strs = StringSplit();
int[] ret = new int[strs.Length];
for (int i = 0 ; i < strs.Length ; i++)
{
ret[i] = int.Parse( strs[i] );
}
return ret;
}
public static long Long() { return long.Parse( ReadedLine[i++] ); }
public static double Double() { return double.Parse( ReadedLine[i++] ); }
public static void wLine( string output = null )
{
Console.WriteLine( output );
}
public static void Finish()
{
Console.Out.Flush();
}
}
YoshiRyu