luoguT30204 偷上网
2024-08-29 10:25:24
\(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;
}
最新文章
- hdu 4038 2011成都赛区网络赛H 贪心 ***
- 安装SQL Server 2008 R2 Enterprise错误:&#39;&#39; is not a valid login or you do not have permission
- 小白学Linux(五)--VI/VIM编辑器
- 25Spring_事务管理的两种机制
- ASP.NET 系列:RBAC权限设计
- angular-xeditable
- Solr单机部署和集群部署
- .Net Core-TagHelpers-Environment
- GNU bash实现机制与源代码简析
- Git客户端(Windows系统)的使用
- VM虚拟机上 实现CentOS 6.X下部署LVS(NAT)+keepalived实现高性能高可用负载均衡
- android wifi讲解 wifi列表显示
- oracle_根据表名拼装语句
- 【USACO12JAN】视频游戏的连击Video Game Combos
- [bzoj4755][Jsoi2016]扭动的回文串
- Nuxt.js调用asyncData
- openwrt如何关掉防火墙?
- 使用DatagramSocket和DatagramPacket进行简单的通信
- [Postman]授权(11)
- debug.keystare找不到的解决办法[转]
热门文章
- DRF之视图组件
- vue-elem-stylus 的mixin用法
- Vue.js(2.x)之列表渲染(v-for/key)
- Java图形界面开发—列出指定目录
- [转]Jetson TX1 开发教程(1)配置与刷机
- Thread.sleep 与Thread.currentThread.sleep
- 博弈论经典算法(一)——对抗搜索与Alpha-Beta剪枝
- python_60_装饰器3
- 说说qwerty、dvorak、colemak三种键盘布局
- 管理员必备的几个Linux系统监控工具