結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー kohaku_kohaku
提出日時 2016-11-21 16:21:31
言語 Java
(openjdk 23)
結果
AC  
実行時間 153 ms / 5,000 ms
コード長 1,177 bytes
コンパイル時間 3,222 ms
コンパイル使用メモリ 78,932 KB
実行使用メモリ 42,444 KB
最終ジャッジ日時 2024-11-27 09:27:31
合計ジャッジ時間 6,504 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    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();
        }
        int c=check(x,y,0);
        if(c==-1){
            System.out.println(-1);
        }else{
            int x4=point(x,c);
            int y4=point(y,c);
            System.out.println(x4+" "+y4);
        }
    }
    static int check(int[]x, int[]y,int z){
        if(z==3){
            return -1;
        }
        int ax = x[z%3]-x[(z+1)%3];
        int bx = x[(z+2)%3]-x[(z+1)%3];
        int cx = x[z%3]-x[(z+2)%3];
        int ay = y[z%3]-y[(z+1)%3];
        int by = y[(z+2)%3]-y[(z+1)%3];
        int cy = y[z%3]-y[(z+2)%3];
        int d1 = ax*ax+ay*ay;
        int d2 = bx*bx+by*by;
        int d3 = cx*cx+cy*cy;
        if(d1==d2&&d1+d2==d3){
            return z;
        }else{
            return check(x,y,z+1);
        }
    }
    static int point(int[]A,int B){
        int n = A[(B+2)%3]-A[(B+1)%3];
        int r = A[B%3]+n;
        return r;
    }
}
0