結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-20 22:22:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 162 ms / 5,000 ms
コード長 1,147 bytes
コンパイル時間 2,485 ms
コンパイル使用メモリ 79,224 KB
実行使用メモリ 42,576 KB
最終ジャッジ日時 2024-04-26 22:12:24
合計ジャッジ時間 7,122 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 158 ms
42,268 KB
testcase_01 AC 135 ms
41,556 KB
testcase_02 AC 158 ms
42,272 KB
testcase_03 AC 157 ms
42,496 KB
testcase_04 AC 129 ms
41,016 KB
testcase_05 AC 135 ms
41,392 KB
testcase_06 AC 119 ms
39,772 KB
testcase_07 AC 135 ms
41,152 KB
testcase_08 AC 136 ms
41,668 KB
testcase_09 AC 133 ms
41,240 KB
testcase_10 AC 131 ms
41,116 KB
testcase_11 AC 155 ms
42,408 KB
testcase_12 AC 118 ms
40,332 KB
testcase_13 AC 161 ms
42,148 KB
testcase_14 AC 162 ms
42,456 KB
testcase_15 AC 128 ms
41,188 KB
testcase_16 AC 158 ms
42,152 KB
testcase_17 AC 118 ms
39,912 KB
testcase_18 AC 154 ms
42,272 KB
testcase_19 AC 134 ms
41,604 KB
testcase_20 AC 157 ms
42,304 KB
testcase_21 AC 157 ms
42,576 KB
testcase_22 AC 157 ms
42,420 KB
testcase_23 AC 155 ms
42,132 KB
testcase_24 AC 157 ms
42,308 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