2015亚洲区北京站网络赛
2015-10-26 13:07
429 查看
A http://hihocoder.com/problemset/problem/1227
题意:给出平面上m个点,任选一个点为圆心,选最小的半径使得恰好n个点在圆内。
解法:枚举圆心,然后对所有点到该圆心距离排序,取第n大的距离作为半径,若第n+1大的在圆内或圆上不合法。
View Code
end
题意:给出平面上m个点,任选一个点为圆心,选最小的半径使得恰好n个点在圆内。
解法:枚举圆心,然后对所有点到该圆心距离排序,取第n大的距离作为半径,若第n+1大的在圆内或圆上不合法。
//#define debug //#define txtout #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<cctype> #include<ctime> #include<iostream> #include<algorithm> #include<vector> #include<queue> #include<stack> #include<map> #include<set> #define mt(a,b) memset(a,b,sizeof(a)) using namespace std; typedef long long LL; const double eps=1e-10; const double pi=acos(-1.0); const int inf=0x3f3f3f3f; const int M=1e2+10; double x; double y[M]; bool zero(double x){ return (x>0?x:-x)<eps; } void init(){ double add=0.25; y[0]=0; for(int i=1;i<30;i++){ y[i]=y[i-1]+add; add*=0.5; } } int solve(){ int res=0; for(int i=0;i<30;i++){ if(zero(x-y[i])) return -1; if(x<y[i]) return res; res+=4; } return 2000; } int main(){ #ifdef txtout freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif init(); int t; while(~scanf("%d",&t)){ while(t--){ scanf("%lf",&x); printf("%d\n",solve()); } } return 0; }
View Code
end
相关文章推荐
- HTTP头文件详解
- iOS开发工具-网络封包分析工具Charles
- POJ 3189 最大流 枚举
- 网络延时-CCF测试往届题(70分)
- 你可以不知道原因,但是,我们不能停止努力。httplook抓取路由配置界面信息
- SSL证书与Https应用部署小结
- Android网络编程http派/申请服务
- 网络异步连接参数解析——利用配置好的APache本地服务器做测试
- SSLstrip 中间人欺骗Https转Http获取密码
- 卷积神经网络(CNN)
- Xcode 7 支持http请求info.plist设置
- Webservice -- HttpCilent 访问Webservice 请求
- Xcode 7 支持http请求info.plist设置
- Xcode7 App Transport Security has blocked a cleartext HTTP (http://) resource load
- 常见的HTTPS攻击方法
- HttpClient和HttpURLConnection的区别
- IOS 设置启动图标 和 启动图片(转载自 http://justsee.iteye.com/blog/2123545)
- http请求服务
- 联想Y450按下Fn+F5不能弹出对话框开启无线网络
- javax.servlet.http.HttpServletRequest;