結果
| 問題 |
No.55 正方形を描くだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-25 19:12:21 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 956 bytes |
| コンパイル時間 | 11,476 ms |
| コンパイル使用メモリ | 223,168 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-14 13:53:46 |
| 合計ジャッジ時間 | 12,105 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
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
}