結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー kano_townkano_town
提出日時 2014-11-23 22:54:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 161 ms / 5,000 ms
コード長 885 bytes
コンパイル時間 3,691 ms
コンパイル使用メモリ 79,808 KB
実行使用メモリ 42,616 KB
最終ジャッジ日時 2024-04-26 22:09:45
合計ジャッジ時間 8,261 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 158 ms
42,616 KB
testcase_01 AC 129 ms
41,000 KB
testcase_02 AC 156 ms
42,468 KB
testcase_03 AC 153 ms
42,484 KB
testcase_04 AC 130 ms
41,008 KB
testcase_05 AC 130 ms
41,368 KB
testcase_06 AC 129 ms
40,968 KB
testcase_07 AC 130 ms
41,424 KB
testcase_08 AC 130 ms
41,116 KB
testcase_09 AC 130 ms
41,048 KB
testcase_10 AC 131 ms
41,552 KB
testcase_11 AC 158 ms
42,572 KB
testcase_12 AC 133 ms
41,096 KB
testcase_13 AC 158 ms
42,280 KB
testcase_14 AC 154 ms
42,360 KB
testcase_15 AC 137 ms
41,108 KB
testcase_16 AC 161 ms
42,128 KB
testcase_17 AC 131 ms
41,408 KB
testcase_18 AC 142 ms
42,152 KB
testcase_19 AC 128 ms
41,232 KB
testcase_20 AC 158 ms
42,168 KB
testcase_21 AC 157 ms
42,168 KB
testcase_22 AC 147 ms
41,628 KB
testcase_23 AC 158 ms
42,416 KB
testcase_24 AC 156 ms
42,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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");
	}
}
0