結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー HiroakiSoftwareHiroakiSoftware
提出日時 2014-11-03 01:51:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,481 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 25,824 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-29 00:25:49
合計ジャッジ時間 1,127 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 WA -
testcase_18 AC 1 ms
4,384 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
yukicoder No.55(Ver2)
※このコードだとケースによってひし形になる可能性がある
作成者:ヒロソフ
*/

#include <stdio.h>

struct  Point {
	double X;
	double Y;
};


int main(void) {
	Point inPoint[3];

	scanf("%lf %lf %lf %lf %lf %lf", &inPoint[0].X, &inPoint[0].Y, &inPoint[1].X, &inPoint[1].Y, &inPoint[2].X, &inPoint[2].Y);
	
	//1点目を中点と仮定する
	double Length[2];
	Point pt_Center;

	Length[0] = (inPoint[1].X - inPoint[0].X) * (inPoint[1].X - inPoint[0].X) + (inPoint[1].Y - inPoint[0].Y) * (inPoint[1].Y - inPoint[0].Y);
	Length[1] = (inPoint[2].X - inPoint[0].X) * (inPoint[2].X - inPoint[0].X) + (inPoint[2].Y - inPoint[0].Y) * (inPoint[2].Y - inPoint[0].Y);

	if (Length[0] == Length[1]) {
		pt_Center.X = (inPoint[1].X + inPoint[2].X) / 2;
		pt_Center.Y = (inPoint[1].Y + inPoint[2].Y) / 2;

		Point diff;
		diff.X = pt_Center.X - inPoint[0].X;
		diff.Y = pt_Center.Y - inPoint[0].Y;

		printf("%d %d\n", (int)(inPoint[0].X + 2 * diff.X), (int)(inPoint[0].Y + 2 * diff.Y));

	} else {
		//2点目を中心と仮定する
		Length[0] = (inPoint[0].X - inPoint[1].X) * (inPoint[0].X - inPoint[1].X) + (inPoint[0].Y - inPoint[1].Y) * (inPoint[0].Y - inPoint[1].Y);
		Length[1] = (inPoint[2].X - inPoint[1].X) * (inPoint[2].X - inPoint[1].X) + (inPoint[2].Y - inPoint[1].Y) * (inPoint[2].Y - inPoint[1].Y);

		if (Length[0] == Length[1]) {
			pt_Center.X = (inPoint[0].X + inPoint[2].X) / 2;
			pt_Center.Y = (inPoint[0].Y + inPoint[2].Y) / 2;

			Point diff;
			diff.X = pt_Center.X - inPoint[1].X;
			diff.Y = pt_Center.Y - inPoint[1].Y;

			printf("%d %d\n", (int)(inPoint[1].X + 2 * diff.X), (int)(inPoint[1].Y + 2 * diff.Y));
		} else {

			//3点目を中心と仮定する
			Length[0] = (inPoint[0].X - inPoint[2].X) * (inPoint[0].X - inPoint[2].X) + (inPoint[0].Y - inPoint[2].Y) * (inPoint[0].Y - inPoint[2].Y);
			Length[1] = (inPoint[1].X - inPoint[2].X) * (inPoint[1].X - inPoint[2].X) + (inPoint[1].Y - inPoint[2].Y) * (inPoint[1].Y - inPoint[2].Y);

			if (Length[0] == Length[1]) {
				pt_Center.X = (inPoint[0].X + inPoint[1].X) / 2;
				pt_Center.Y = (inPoint[0].Y + inPoint[1].Y) / 2;

				Point diff;
				diff.X = pt_Center.X - inPoint[2].X;
				diff.Y = pt_Center.Y - inPoint[2].Y;

				printf("%d %d\n", (int)(inPoint[2].X + 2 * diff.X), (int)(inPoint[2].Y + 2 * diff.Y));
			} else {
				printf("-1\n");
			}
		}
	}

	return 0;
}
0