hiho week 111 register

Ended

Participants:456

Verdict:Accepted
Score:100 / 100
Submitted:2016-08-20 16:15:41

Lang:Java

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double x0 = in.nextDouble();
        double y0 = in.nextDouble();
        double r = in.nextDouble();         
        double D = 0;
        int X=0,Y=0;
        for(int x=(intMath.ceil(x0-r);x<=(int)Math.floor(x0+r);x++){
            double d = Math.sqrt(r*r-(x-x0)*(x-x0));
            int y1 = (int)Math.ceil(y0-d),y2 = (int)Math.floor(y0+d);
            int y = Math.abs(y1-y0)>Math.abs(y2-y0)?y1:y2;
            if((x-x0)*(x-x0)+(y-y0)*(y-y0)>=D){
                X=x;
                Y=y;
                D=(x-x0)*(x-x0)+(y-y0)*(y-y0);
            }
        }
        System.out.println(X+" "+Y);
    }
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX