답안 #27193

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
27193 2017-07-10T09:02:47 Z TAMREF 두 개의 원 (balkan11_2circles) C++11
10 / 100
0 ms 3784 KB
#include <bits/stdc++.h>
using namespace std;
typedef double lf;
struct pt{
    lf x,y;
    pt(int _x=0,int _y=0):x((double)_x),y((double)_y){}
    pt operator- (pt z){return pt(x-z.x,y-z.y);}
};
inline lf d(pt u, pt v){
    return ((u.x-v.x)*(u.x-v.x)+(u.y-v.y)*(u.y-v.y));
}
inline lf angle(pt u, pt v, pt w){
    lf a=d(u,v),b=d(v,w),c=d(u,w);
    return acos((a+b-c)/(2*sqrt(a*b)));
}
pt t[100005];
int N;
bool valid3(lf r){
    for(int x=0;x<3;x++){
        lf  the1 = angle(t[(x+2)%3],t[x],t[(x+1)%3]),
            the2 = angle(t[x],t[(x+1)%3],t[(x+2)%3]),
            d12 = sqrt(d(t[x],t[(x+1)%3]));
        if(d12-(r/tan(the2/2))-(r/tan(the1/2))>2*r) return true;
    }
    return false;
}
int main(){
    scanf("%d",&N);
    if(N>3) return !printf("0.000\n");
    for(int i=0,x,y;i<N;i++){
        scanf("%d%d",&x,&y);
        t[i]=pt(x,y);
    }
    lf l=1e-7,h=1e7,m;
    while(h-l>=1e-3){
        m=(l+h)/2.0;
        if(valid3(m)) l=m;
        else h=m;
    }
    printf("%.3f\n",m);
}

Compilation message

2circles.cpp: In function 'int main()':
2circles.cpp:28:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
                   ^
2circles.cpp:31:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&x,&y);
                            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3784 KB Output is correct
2 Incorrect 0 ms 3784 KB Output isn't correct
3 Incorrect 0 ms 3784 KB Output isn't correct
4 Incorrect 0 ms 3784 KB Output isn't correct
5 Incorrect 0 ms 3784 KB Output isn't correct
6 Incorrect 0 ms 3784 KB Output isn't correct
7 Incorrect 0 ms 3784 KB Output isn't correct
8 Incorrect 0 ms 3784 KB Output isn't correct
9 Incorrect 0 ms 3784 KB Output isn't correct
10 Incorrect 0 ms 3784 KB Output isn't correct