結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-20 22:22:19
言語 Java19
(openjdk 21)
結果
AC  
実行時間 155 ms / 5,000 ms
コード長 1,147 bytes
コンパイル時間 4,644 ms
コンパイル使用メモリ 77,156 KB
実行使用メモリ 58,804 KB
最終ジャッジ日時 2023-08-09 07:30:52
合計ジャッジ時間 7,275 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
56,960 KB
testcase_01 AC 125 ms
54,052 KB
testcase_02 AC 154 ms
56,668 KB
testcase_03 AC 153 ms
56,768 KB
testcase_04 AC 123 ms
55,756 KB
testcase_05 AC 126 ms
55,868 KB
testcase_06 AC 123 ms
55,888 KB
testcase_07 AC 121 ms
55,792 KB
testcase_08 AC 126 ms
55,792 KB
testcase_09 AC 126 ms
55,896 KB
testcase_10 AC 125 ms
55,752 KB
testcase_11 AC 152 ms
56,708 KB
testcase_12 AC 128 ms
55,876 KB
testcase_13 AC 153 ms
56,648 KB
testcase_14 AC 152 ms
56,780 KB
testcase_15 AC 124 ms
55,876 KB
testcase_16 AC 155 ms
54,944 KB
testcase_17 AC 123 ms
55,912 KB
testcase_18 AC 150 ms
56,520 KB
testcase_19 AC 123 ms
56,488 KB
testcase_20 AC 151 ms
56,632 KB
testcase_21 AC 151 ms
56,792 KB
testcase_22 AC 153 ms
58,804 KB
testcase_23 AC 151 ms
56,968 KB
testcase_24 AC 148 ms
56,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int[] x = new int [3];
        int[] y = new int [3];
        for(int i=0; i<3; i++){
            x[i]=koko.nextInt();
            y[i]=koko.nextInt();
        }
        int[] dis = new int[3];
        int[] a = new int[3];
        for(int i=0; i<2; i++){
            a[i]=((x[i+1]-x[i])*(x[i+1]-x[i]))+((y[i+1]-y[i])*(y[i+1]-y[i]));
            dis[i]=a[i];
        }
        a[2]=((x[0]-x[2])*(x[0]-x[2]))+((y[0]-y[2])*(y[0]-y[2]));
        dis[2]=a[2];
        Arrays.sort(a);
        if(a[0]==a[1]&&a[0]+a[1]==a[2]){
            int xa=0;
            int ya=0;
            if(dis[0]>dis[1]){
                xa=x[0]+x[1]-x[2];
                ya=y[0]+y[1]-y[2];
            }else if(dis[0]==dis[1]){
                xa=x[2]+x[0]-x[1];
                ya=y[2]+y[0]-y[1];
            }else{
                xa=x[2]+x[1]-x[0];
                ya=y[2]+y[1]-y[0];
            }
            System.out.println(xa+" "+ya);
        }else{
            System.out.println(-1);
        }
    }
}
0