http://172.20.6.3/Problem_Show.asp?id=1502
这种题用了快一天才写出来也是真的辣鸡。主要思路就是计算一下被挡住的弧度然后对弧度进行贪心。
最开始比较困扰的是求弧度值及其起始位置的部分,弧度值很好求,位置有点恶心,我的起始位置设置的是圆的十二点方向顺时针到起始位置的弧度值,然后我分了四种情况讨论(因为遮挡的方向有两种不同情况,遮挡部分弧度值与180度的关系又是两种情况),应该是有更简单的方法的,但是我只能想出来这种了。。。

代码

 #include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
const int maxn=;
const double eps=0.0000001;
long long n;
double r[maxn]={},x[maxn]={},y[maxn]={};
struct nod{
double id,v;
}e[maxn];
int tot;
bool mmp(nod aa,nod bb){
return aa.id<bb.id;
}
double getit(int i){
tot=;double cnt=;
for(int j=n;j>i;j--){
double w=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
if(r[i]+r[j]-w<=||r[i]-r[j]-w>=)continue;
if(r[j]-r[i]-w>=) return ; double z=(r[i]*r[i]-r[j]*r[j]+w*w)/(*w);
double h=acos(z/r[i])*; double xx=x[i]+(x[j]-x[i])/w*z,yy=y[i]+(y[j]-y[i])/w*z;
double w1=sqrt((x[i]-xx)*(x[i]-xx)+(y[i]+z-yy)*(y[i]+z-yy));
double h2=asin(w1//z)*;
if(xx<x[i]){
if(h2<)h2=-h2;
else if(h2>) h2=*M_PI-h2; }
else if (xx>x[i]){if(h2<) h2=*M_PI+h2;}
h2=h2-h/;
if(h2<)h2+=*M_PI;
h=h2+h;
if(h>*M_PI){
e[++tot].id=h2;e[tot].v=*M_PI;
e[++tot].id=;e[tot].v=h-*M_PI;
}else{e[++tot].id=h2;e[tot].v=h;}
}
sort(e+,e++tot,mmp);
double ll=0.0,rr=0.0;
for(int j=;j<=tot;j++){
if(e[j].id-rr<){
if(e[j].v-rr>){
rr=e[j].v;
}
}
else if(e[j].v-rr>){
cnt+=rr-ll;
rr=e[j].v;ll=e[j].id;
}
}
cnt+=rr-ll;
return r[i]*(M_PI*-cnt);
}
int main(){
//freopen("wtf.in","r",stdin);
scanf("%d",&n);
for(int i=;i<=n;i++){
scanf("%lf%lf%lf",&r[i],&x[i],&y[i]);
}double ans=;
for(int i=n;i>=;i--){
ans+=getit(i);
}printf("%.3f\n",ans);
return ;
}

最新文章

  1. 如何解决流程开发中SheetRadioButtonList页面取值问题
  2. 【C#】调度程序进程已挂起,但消息仍在处理中;
  3. mac os 体验
  4. [转]SpringMVC使用@ResponseBody时返回json的日期格式、@DatetimeFormat使用注意
  5. CSS的class、id、css文件名的常用命名规则
  6. [Android Memory] Android Lint简介(转载)
  7. JSONObject put,accumulate,element的区别(转载)
  8. 图解Windows Server 2012 桌面图标
  9. tcp协议中mss的理解
  10. ASP.NET MVC 4应用程序文件夹
  11. Elasticsearch学习2--Elasticsearch数据类型简介
  12. ArrayList和LinkedList源码
  13. 进阶篇之纯css+字体实现五角星(半颗星)评分
  14. Android中的分层----service 层,domain层,dao 层,action层等设计
  15. RNN/LSTM/GRU/seq2seq公式推导
  16. ASP.NET多行文本框限制字符个数
  17. saltstack主机管理项目【day39】:主机管理项目开发
  18. Python集成开发环境搭建
  19. 论mysql主从复制里面的那些坑
  20. http://blog.csdn.net/beitiandijun/article/details/41678251

热门文章

  1. codechef September Challenge 2017 Fill The Matrix
  2. [POI2004] SZP (贪心+拓扑排序)
  3. ubuntu 玩转 nodejs
  4. bzoj 2321 数学
  5. Python 编码问题:出现中文乱码-- (转)
  6. spring mvc 提供的几个常用的扩展点
  7. js作用域与上下文
  8. linux===linux后台运行和关闭、查看后台任务(转)
  9. 一个真正的客户端非阻塞的 connect
  10. JS面试题第一弹