結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー yukirinyukirin
提出日時 2016-02-25 19:12:21
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 956 bytes
コンパイル時間 15,569 ms
コンパイル使用メモリ 221,720 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 22:18:29
合計ジャッジ時間 16,334 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	sc.Split(bufio.ScanWords)
	ps := make([][2]int, 3)
	for i := range ps {
		ps[i] = [2]int{nextInt(), nextInt()}
	}

	ps = append(ps, ps[2])
	r := -1
	for i := range ps[:len(ps)-1] {
		n, n2 := (i+1)%3, (i+2)%3
		b1 := [2]int{ps[i][0] - ps[n][0], ps[i][1] - ps[n][1]}
		b2 := [2]int{ps[i][0] - ps[n2][0], ps[i][1] - ps[n2][1]}
		h1 := math.Hypot(float64(b1[0]), float64(b1[1]))
		h2 := math.Hypot(float64(b2[0]), float64(b2[1]))
		if b1[0]*b2[0]+b1[1]*b2[1] == 0 && h1 == h2 {
			r = i
			break
		}
	}
	if r == -1 {
		fmt.Println(-1)
		return
	}

	n, n2 := (r+1)%3, (r+2)%3
	dx, dy := ps[n][0]-ps[r][0], ps[n][1]-ps[r][1]
	fmt.Println(ps[n2][0]+dx, ps[n2][1]+dy)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextLine())
	return i
}
0