結果

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

ソースコード

diff #

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  int x[4], y[4];
  for(int i=0; i<3; ++i){
    cin >> x[i] >> y[i];
  }

  for(int i=0; i<3; ++i){
    if(hypot(x[i]-x[(i+1)%3], y[i]-y[(i+1)%3]) == hypot(x[i]-x[(i+2)%3], y[i]-y[(i+2)%3])){
      if(!((x[(i+1)%3] - x[i]) * (x[(i+2)%3] - x[i]) + (y[(i+1)%3] - y[i]) * (y[(i+2)%3] - y[i]))){
        x[3] = x[(i+1)%3] + x[(i+2)%3] - x[i];
        y[3] = y[(i+1)%3] + y[(i+2)%3] - y[i];
        cout << x[3] << " " << y[3] << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}
0