結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー lunnearlunnear
提出日時 2019-02-11 04:42:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,347 bytes
コンパイル時間 580 ms
コンパイル使用メモリ 58,872 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 21:17:00
合計ジャッジ時間 1,636 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <math.h>

class Vector2
{
public:
    Vector2(short x = 0, short y = 0):x(x), y(y){}
    
public:
    short x, y;
    
public:
    short LengthSq(){return (x * x + y * y);}
    float Length(){return sqrtf(x * x + y * y);}
    
public:
    Vector2 operator+(Vector2 &a){return Vector2(x + a.x, y + a.y);}
    Vector2 operator-(Vector2 &a){return Vector2(x - a.x, y - a.y);}
};

int main()
{
    Vector2 v[4];
    for(int i = 0; i < 3; i++)
    {
        std::cin >> v[i].x >> v[i].y;
    }
    
    Vector2 e[5];
    e[0] = v[1] - v[0];
    e[1] = v[2] - v[1];
    e[2] = v[0] - v[2];
    

    if(e[0].LengthSq() == e[1].LengthSq())
    {
        v[3] = v[0] + e[1];
        
        e[3] = v[2] - v[0];
        e[4] = v[3] - v[1];
    }
    else if(e[1].LengthSq() == e[2].LengthSq())
    {
        v[3] = v[1] + e[2];
        
        e[3] = v[1] - v[0];
        e[4] = v[3] - v[2];
    }
    else if(e[2].LengthSq() == e[0].LengthSq())
    {
        v[3] = v[2] + e[0];
        
        e[3] = v[2] - v[1];
        e[4] = v[3] - v[0];
    }
    else
    {
        std::cout << "-1" << std::endl;
        return 0;
    }
    

    if(e[3].LengthSq() != e[4].LengthSq())
    {
        std::cout << "-1" << std::endl;
        return 0;
    }
    
    std::cout << v[3].x << " " << v[3].y << std::endl;
    return 0;
}
0