結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー GrenacheGrenache
提出日時 2015-11-03 20:06:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 1,063 bytes
コンパイル時間 4,664 ms
コンパイル使用メモリ 77,300 KB
実行使用メモリ 41,464 KB
最終ジャッジ日時 2024-04-26 22:16:39
合計ジャッジ時間 7,964 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
41,108 KB
testcase_01 AC 128 ms
41,192 KB
testcase_02 AC 133 ms
41,384 KB
testcase_03 AC 134 ms
41,172 KB
testcase_04 AC 131 ms
41,080 KB
testcase_05 AC 130 ms
40,928 KB
testcase_06 AC 134 ms
41,272 KB
testcase_07 AC 134 ms
41,016 KB
testcase_08 AC 118 ms
40,068 KB
testcase_09 AC 134 ms
41,304 KB
testcase_10 AC 119 ms
40,060 KB
testcase_11 AC 134 ms
41,244 KB
testcase_12 AC 133 ms
41,372 KB
testcase_13 AC 121 ms
39,868 KB
testcase_14 AC 134 ms
41,344 KB
testcase_15 AC 132 ms
41,308 KB
testcase_16 AC 133 ms
41,004 KB
testcase_17 AC 132 ms
41,424 KB
testcase_18 AC 135 ms
40,972 KB
testcase_19 AC 134 ms
41,076 KB
testcase_20 AC 132 ms
41,464 KB
testcase_21 AC 134 ms
41,240 KB
testcase_22 AC 135 ms
41,140 KB
testcase_23 AC 122 ms
39,996 KB
testcase_24 AC 131 ms
41,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder55 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int[] x = new int[3];
        int[] y = new int[3];
        for (int i = 0; i < 3; i++) {
        	x[i] = sc.nextInt();
        	y[i] = sc.nextInt();
        }

        for (int i = 0; i < 3; i++) {
        	int xx1 = x[(i + 1) % 3] - x[i];
        	int yy1 = y[(i + 1) % 3] - y[i];
        	int xx2 = x[(i + 2) % 3] - x[i];
        	int yy2 = y[(i + 2) % 3] - y[i];

            if (Geom.dot(xx1, yy1, xx2, yy2) == 0 && Geom.sumofsquare(xx1, yy1) == Geom.sumofsquare(xx2, yy2)) {
            	System.out.printf("%d %d\n", xx1 + xx2 + x[i], yy1 + yy2 + y[i]);
            	
            	sc.close();
            	return;
            }
        }

		System.out.println("-1");
        
        sc.close();
    }

	private static class Geom {
		static int dot(int xa, int ya, int xb, int yb) {
			return xa * xb + ya * yb;
		}
		static int sumofsquare(int xa, int ya) {
			return xa * xa + ya * ya;
		}
	}
}
0