結果
問題 |
No.24 数当てゲーム
|
ユーザー |
|
提出日時 | 2017-12-16 22:43:29 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 36 ms / 5,000 ms |
コード長 | 2,317 bytes |
コンパイル時間 | 1,468 ms |
コンパイル使用メモリ | 113,608 KB |
実行使用メモリ | 27,120 KB |
最終ジャッジ日時 | 2024-12-14 21:57:54 |
合計ジャッジ時間 | 2,009 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
コンパイルメッセージ
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; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; namespace yukicore { //this algorithm think by claclator class Element<T> where T : IEquatable<T> { public IEnumerable<T> nums; public Element(IEnumerable<T> nums) => this.nums = nums; public Element(Element<T> e) => this.nums = e.nums; public static Element<T> operator -(Element<T> a, Element<T> b) { List<T> rtn = new List<T>(); foreach (var num in a.nums) { if (b.nums.All(x => !x.Equals(num))) rtn.Add(num); } return new Element<T>(rtn); } public static Element<T> operator +(Element<T> a, Element<T> b) { var rtn = new List<T>(); rtn.AddRange(a.nums); rtn.AddRange(b.nums); return new Element<T>(rtn.Distinct().ToArray()); } public static Element<T> operator *(Element<T> a, Element<T> b) { var rtn = new List<T>(); foreach (var num in a.nums) { if (b.nums.Contains(num)) rtn.Add(num); } return new Element<T>(rtn.ToArray()); } } internal class Program { private static void Main(string[] args) { Element<int> mother = new Element<int>(Enumerable.Range(0, 10)); Element<int> rtn = new Element<int>(Enumerable.Range(0, 10)); Console.ReadLine(); while (true) { var tmp = Console.ReadLine(); if (tmp == null || tmp == "") break; var spl = tmp.Split(' '); var inputs = spl.Take(4).Select(x => int.Parse(x)).ToArray(); var flag = spl.Last() == "YES" ? true : false; Element<int> input; if (flag) input = new Element<int>(inputs); else input = new Element<int>(mother - new Element<int>(inputs)); rtn *= input; } Console.WriteLine( rtn.nums.ToArray()[0]); } } }