結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー 6soukiti296soukiti29
提出日時 2017-07-31 02:58:15
言語 Nim
(2.0.2)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,194 bytes
コンパイル時間 3,145 ms
コンパイル使用メモリ 68,004 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-12 13:48:37
合計ジャッジ時間 4,282 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import sequtils,strutils,math

proc `=~`(x,y : float64):bool=
    if abs(x - y) < abs(x) / 1_000_000:
        return true
    else:
        return false


proc length(s1,t1,s2,t2 : int):float64 =
    var
        s = ((s1 - s2) * (s1 - s2)).float64
        t = ((t1 - t2) * (t1 - t2)).float64
    return sqrt(s + t)

var
    x1,y1,x2,y2,x3,y3 : int
    x,y : int
(x1,y1,x2,y2,x3,y3) = stdin.readline.split.map(parseInt)

var flag : bool
var px,py : float64

var
    a = length(x1,y1,x2,y2)
    b = length(x2,y2,x3,y3)
    c = length(x3,y3,x1,y1)

if b < c and a < c:
    if b * b + a * a =~ c * c and a =~ b:
        (px,py) = ((x3 + x1) / 2,(y3 + y1) / 2)
        x = round(px * 2).int - x2
        y = round(py * 2).int - y2
        flag = true
elif b < a and c < a:
    if b * b + c * c =~ a * a and b =~ c:
        (px,py) = ((x2 + x1) / 2,(y2 + y1) / 2)
        x = round(px * 2).int - x3
        y = round(py * 2).int - y3
        flag = true
elif a < b and c < b:
    if a * a + c * c =~ b * b and c =~ a:
        (px,py) = ((x3 + x2) / 2,(y3 + y2) / 2)
        x = round(px * 2).int - x1
        y = round(py * 2).int - y1
        flag = true

if flag:
    echo x," ",y
else:
    echo -1
0