結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
|
提出日時 | 2014-11-23 22:54:42 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 161 ms / 5,000 ms |
コード長 | 885 bytes |
コンパイル時間 | 3,731 ms |
コンパイル使用メモリ | 79,748 KB |
実行使用メモリ | 55,116 KB |
最終ジャッジ日時 | 2024-11-14 13:47:09 |
合計ジャッジ時間 | 8,300 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
import java.util.Scanner;public class Yukicoder55 {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int[] x = new int[4];int[] y = new int[4];int[][] pat = {{0, 1, 2}, {1, 0, 2}, {2, 0, 1}};for (int i = 0; i < 3; i++) {x[i] = sc.nextInt();y[i] = sc.nextInt();}for (int i = 0; i < 3; i++) {if (Math.hypot(x[pat[i][1]] - x[pat[i][0]], y[pat[i][1]] - y[pat[i][0]]) == Math.hypot(x[pat[i][2]] - x[pat[i][0]], y[pat[i][2]] -y[pat[i][0]])) {x[3] = x[pat[i][1]] + (x[pat[i][2]] - x[pat[i][0]]);y[3] = y[pat[i][1]] + (y[pat[i][2]] - y[pat[i][0]]);if (Math.hypot(x[3] - x[pat[i][0]], y[3] - y[pat[i][0]]) == Math.hypot(x[pat[i][2]] - x[pat[i][1]], y[pat[i][2]] - y[pat[i][1]])) {System.out.println(x[3] + " " + y[3]);return;}}}System.out.println("-1");}}