結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー ku_material_roku_material_ro
提出日時 2016-09-28 17:37:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,051 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 62,464 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 06:17:42
合計ジャッジ時間 1,413 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;


int main(){
	int x[3];
	int y[3];
	int ansx, ansy;
	int a1, a2;
	int n, m, l;
	int flug = 0;
	cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];
	for (int i = 0; i < 3; i++){
		//cout << i << endl;
		if(i == 0){
			n = 0;
			m = 1;
			l = 2;
		}if (i == 1){
			n = 1;
			m = 2;
			l = 0;
		}
		if (i == 2) {
			n = 2;
			m = 0;
			l = 1;
		}
		if ((y[n] - y[m]) != 0 && (y[m] - y[l]) != 0){
			a1 = ((x[n] - x[m])*(x[m] - x[l])) / ((y[n] - y[m])*(y[m] - y[l]));
			if (a1 == -1){
				flug = 1;
				break;
			}
		}
		else{
			if ((x[m] == x[n] && y[m] == y[l]) || (x[m] == x[l] && y[m] == y[n])){
				flug = 1;
				//cout << "test" << endl;
				break;
			}
		}
		
		
		
	}
	ansx = x[l] - (x[m] - x[n]);
	ansy = y[l] - (y[m] - y[n]);
	if (pow((x[m] - x[n]), 2) + pow((y[m] - y[n]), 2) != pow((x[m] - x[l]), 2) + pow((y[m] - y[l]), 2)){
		flug = 0;
	}
	if (flug == 1){
		cout << ansx <<" "<< ansy << endl;
	}
	else{
		cout << "-1" << endl;
	}
	return 0;
}
0