\(n=1\) 时特判四角,其余时刻圆的面积和必小于正方形面积,随机点出来判断就行了。

stm 随机算法……

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
using namespace std;
int n;
double l, xx[15], yy[15];
const double eps=1e-6;
double dis(double x, double y){
return sqrt(x*x+y*y);
}
int main(){
srand(time(NULL));
cin>>n>>l;
for(int i=1; i<=n; i++)
cin>>xx[i]>>yy[i];
if(n==1){
double r=dis(xx[1], yy[1]);
if(r>=l+eps){
printf("0.0 0.0\n");
return 0;
}
r=dis(l-xx[1], yy[1]);
if(r>=l+eps){
printf("%f 0.0\n", l);
return 0;
}
r=dis(xx[1], l-yy[1]);
if(r>=l+eps){
printf("0.0 %f\n", l);
return 0;
}
r=dis(l-xx[1], l-yy[1]);
if(r>=l+eps){
printf("%f %f\n", l, l);
return 0;
}
printf("GG\n");
}
else{
while(true){
double x=rand(), y=rand();
x/=2147483647;
y/=2147483647;
x*=l;
y*=l;
bool flag=true;
for(int i=1; i<=n; i++)
if(dis(xx[i]-x,yy[i]-y)<l/n+eps)
flag = false;
if(flag){
printf("%.12f %.12f\n", x, y);
break;
}
}
}
return 0;
}

最新文章

  1. hdu 4038 2011成都赛区网络赛H 贪心 ***
  2. 安装SQL Server 2008 R2 Enterprise错误:&#39;&#39; is not a valid login or you do not have permission
  3. 小白学Linux(五)--VI/VIM编辑器
  4. 25Spring_事务管理的两种机制
  5. ASP.NET 系列:RBAC权限设计
  6. angular-xeditable
  7. Solr单机部署和集群部署
  8. .Net Core-TagHelpers-Environment
  9. GNU bash实现机制与源代码简析
  10. Git客户端(Windows系统)的使用
  11. VM虚拟机上 实现CentOS 6.X下部署LVS(NAT)+keepalived实现高性能高可用负载均衡
  12. android wifi讲解 wifi列表显示
  13. oracle_根据表名拼装语句
  14. 【USACO12JAN】视频游戏的连击Video Game Combos
  15. [bzoj4755][Jsoi2016]扭动的回文串
  16. Nuxt.js调用asyncData
  17. openwrt如何关掉防火墙?
  18. 使用DatagramSocket和DatagramPacket进行简单的通信
  19. [Postman]授权(11)
  20. debug.keystare找不到的解决办法[转]

热门文章

  1. DRF之视图组件
  2. vue-elem-stylus 的mixin用法
  3. Vue.js(2.x)之列表渲染(v-for/key)
  4. Java图形界面开发—列出指定目录
  5. [转]Jetson TX1 开发教程(1)配置与刷机
  6. Thread.sleep 与Thread.currentThread.sleep
  7. 博弈论经典算法(一)——对抗搜索与Alpha-Beta剪枝
  8. python_60_装饰器3
  9. 说说qwerty、dvorak、colemak三种键盘布局
  10. 管理员必备的几个Linux系统监控工具