結果
| 問題 |
No.185 和風
|
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2024-10-10 23:29:18 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 35 ms / 1,000 ms |
| コード長 | 1,711 bytes |
| コンパイル時間 | 2,791 ms |
| コンパイル使用メモリ | 115,340 KB |
| 実行使用メモリ | 28,428 KB |
| 最終ジャッジ日時 | 2024-10-10 23:29:22 |
| 合計ジャッジ時間 | 2,032 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 |
コンパイルメッセージ
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.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("2");
WillReturn.Add("3 5");
WillReturn.Add("7 9");
//2
//□に3を足すと5になり,7を足すと9になるってことは,□は2だね
}
else if (InputPattern == "Input2") {
WillReturn.Add("2");
WillReturn.Add("3 5");
WillReturn.Add("7 10");
//-1
}
else if (InputPattern == "Input3") {
WillReturn.Add("1");
WillReturn.Add("8 2");
//-1
//正整数しか知らないから,8を足すと2になるようなものなんてわかんないや
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
var SikakuSet = new HashSet<int>();
foreach (string EachStr in InputList.Skip(1)) {
int[] wkArr = EachStr.Split(' ').Select(X => int.Parse(X)).ToArray();
SikakuSet.Add(wkArr[1] - wkArr[0]);
}
if (SikakuSet.Count >= 2) { //ユニーク解でなければNG
Console.WriteLine(-1); return;
}
if (SikakuSet.First() <= 0) { //正整数の解でなければNG
Console.WriteLine(-1); return;
}
Console.WriteLine(SikakuSet.First());
}
}
aketijyuuzou