結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 2019-12-30 13:23:00 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 160 ms / 5,000 ms |
コード長 | 1,333 bytes |
コンパイル時間 | 3,054 ms |
コンパイル使用メモリ | 85,908 KB |
実行使用メモリ | 42,420 KB |
最終ジャッジ日時 | 2024-11-08 02:59:17 |
合計ジャッジ時間 | 7,234 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
import java.util.*;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);Point p1 = new Point(sc.nextInt(), sc.nextInt());Point p2 = new Point(sc.nextInt(), sc.nextInt());Point p3 = new Point(sc.nextInt(), sc.nextInt());int d1 = p2.getD(p3);int d2 = p3.getD(p1);int d3 = p1.getD(p2);Point p4;if (d1 == d2 && d1 * 2 == d3) {p4 = p3.getAnother(p1, p2);} else if (d2 == d3 && d2 * 2 == d1) {p4 = p1.getAnother(p2, p3);} else if (d3 == d1 && d3 * 2 == d2) {p4 = p2.getAnother(p3, p1);} else {System.out.println(-1);return;}System.out.println(p4);}static class Point {int x;int y;public Point(int x, int y) {this.x = x;this.y = y;}public int getD(Point another) {return (x - another.x) * (x - another.x) + (y - another.y) * (y - another.y);}public Point getAnother(Point p1, Point p2) {return new Point(p1.x + p2.x - x, p1.y + p2.y - y);}public String toString() {return x + " " + y;}}}