hiho week 111 register

Ended

Participants:456

Verdict:Accepted
Score:100 / 100
Submitted:2016-08-15 16:35:04

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    double x0, y0, r;
    cin>>x0>>y0>>r;
    int x, y1, y2;
    double max=0,dist1,dist2,dst;
    int rx,ry;
    for(x=floor(x0+r); x>=ceil(x0-r); x--){
        y1=floor(y0+sqrt(pow(r,2)-pow(x-x0,2)));
        y2=ceil(y0-sqrt(pow(r,2)-pow(x-x0,2)));
        dist1=pow(x-x0,2)+pow(y1-y0,2);
        dist2=pow(x-x0,2)+pow(y2-y0,2);
        dst=dist1>=dist2? dist1: dist2;
        if(dst>max){
            max=dst;
            rx=x;ry=dist1>=dist2?y1:y2;
        }
    }
    cout<<rx<<' '<<ry;
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX