結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-21 16:21:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 157 ms / 5,000 ms
コード長 1,177 bytes
コンパイル時間 2,203 ms
コンパイル使用メモリ 75,904 KB
実行使用メモリ 57,068 KB
最終ジャッジ日時 2023-08-18 06:09:55
合計ジャッジ時間 7,075 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
56,760 KB
testcase_01 AC 125 ms
55,596 KB
testcase_02 AC 154 ms
56,980 KB
testcase_03 AC 152 ms
56,776 KB
testcase_04 AC 123 ms
56,120 KB
testcase_05 AC 122 ms
55,412 KB
testcase_06 AC 124 ms
55,732 KB
testcase_07 AC 127 ms
55,592 KB
testcase_08 AC 126 ms
55,660 KB
testcase_09 AC 126 ms
55,912 KB
testcase_10 AC 125 ms
56,080 KB
testcase_11 AC 150 ms
57,068 KB
testcase_12 AC 124 ms
55,996 KB
testcase_13 AC 149 ms
56,752 KB
testcase_14 AC 150 ms
56,896 KB
testcase_15 AC 126 ms
55,736 KB
testcase_16 AC 152 ms
56,664 KB
testcase_17 AC 125 ms
56,020 KB
testcase_18 AC 157 ms
56,676 KB
testcase_19 AC 124 ms
55,828 KB
testcase_20 AC 151 ms
56,880 KB
testcase_21 AC 152 ms
56,860 KB
testcase_22 AC 155 ms
56,928 KB
testcase_23 AC 156 ms
56,684 KB
testcase_24 AC 153 ms
56,916 KB
権限があれば一括ダウンロードができます

ソースコード

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