結果
問題 |
No.55 正方形を描くだけの簡単なお仕事です。
|
ユーザー |
![]() |
提出日時 | 2016-04-06 00:10:30 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 27 ms / 5,000 ms |
コード長 | 2,751 bytes |
コンパイル時間 | 894 ms |
コンパイル使用メモリ | 115,176 KB |
実行使用メモリ | 26,412 KB |
最終ジャッジ日時 | 2024-11-14 13:54:17 |
合計ジャッジ時間 | 2,356 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
コンパイルメッセージ
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.Text; public class Program { public void Proc(){ Reader.IsDebug = false; int[] inpt = Reader.GetInt(); int x1 = inpt[0]; int y1 = inpt[1]; int x2 = inpt[2]; int y2 = inpt[3]; int x3 = inpt[4]; int y3 = inpt[5]; int len1 = (int)(Math.Pow((x1 - x2),2) + Math.Pow((y1-y2), 2)); int len2 = (int)(Math.Pow((x1 - x3), 2) + Math.Pow(y1-y3, 2)); int aX1 = x1; int aY1 = y1; int aX2; int aY2; int aX3; int aY3; if(len1 < len2) { aX2 = x2; aY2 = y2; aX3 = x3; aY3 = y3; } else { aX2 = x3; aY2 = y3; aX3 = x2; aY3 = y2; } int tX1 = aX1 + (aY1 - aY2); int tY1 = aY1 - (aX1 - aX2); int len3 = (int)(Math.Pow(aX3 - tX1, 2) + Math.Pow(aY3 - tY1, 2)); if(len3 == 0) { int tX2 = aX3 - (aX1 - aX2); int tY2 = aY3 - (aY1 - aY2); Console.WriteLine(tX2 + " " + tY2); } else if(len3 == Math.Min(len1, len2)) { Console.WriteLine(tX1 + " " + tY1); } else { tX1 = aX1 - (aY1 - aY2); tY1 = aY1 + (aX1 - aX2); len3 = (int)(Math.Pow(aX3 - tX1, 2) + Math.Pow(aY3 - tY1, 2)); if(len3 == 0) { int tX2 = aX3 - (aX1 - aX2); int tY2 = aY3 - (aY1 - aY2); Console.WriteLine(tX2 + " " + tY2); } else if(len3 == Math.Min(len1, len2)) { Console.WriteLine(tX1 + " " + tY1); } else { Console.WriteLine(-1); } } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } } class Reader { public static bool IsDebug = true; private static System.IO.StringReader sr; public static string ReadLine() { if(IsDebug) { if(sr == null) { sr = new System.IO.StringReader(initStr.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ') { string[] inpt = ReadLine().Split(delimiter); int[] ret = new int[inpt.Length]; for(int i=0; i<inpt.Length; i++) { ret[i] = int.Parse(inpt[i]); } return ret; } private static string initStr = @" 0 0 2 0 2 1 "; }