結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー Ryogo1008
提出日時 2014-11-06 01:14:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 961 bytes
コンパイル時間 609 ms
コンパイル使用メモリ 65,420 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-14 13:43:42
合計ジャッジ時間 1,397 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef complex<double> P;

#define EPS (1e-10)

#define EQ(a,b) (abs((a)-(b))<EPS)

#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )

// 内積 (dot product) : a・b = |a||b|cosΘ
double dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}

int norm2(P p){
	return p.real()*p.real() +p.imag()*p.imag();
}
int main(){
	 P data[3];
	for(int i=0;i<3;i++){
	 int re,im;
		cin>>re>>im;
		data[i]=P(re,im);
	}
	
	for(int i=0;i<3;i++){
		int tmp=0;
		P v1,v2;
		for(int j=0;j<3;j++){
			if(i!=j){
				if(tmp==0){
					v1=data[j]-data[i];
					tmp++;
				}
				else {
					v2=data[j]-data[i];
				}
			}
		}
			
			if(norm2(v1)==norm2(v2) && dot(v1,v2)==0){
				P v3=data[i]+v1+v2;
				cout<<v3.real()<<" "<<v3.imag()<<endl;
				return 0;
			}
		}
	
	
	cout<<-1<<endl;
}
0