萌新求助qwq,有大佬能帮忙调一下吗

P1325 雷达安装

@[Lycan!](/user/210122) 要用$double$
by OItby @ 2020-01-11 19:21:40


这只是错误之一
by OItby @ 2020-01-11 19:23:24


改正的代码 ```cpp #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; double x[1100]; double y[1100]; struct dao{ double l,r; }a[2005]; bool cmp(dao a,dao b){ return a.r<b.r; } int main(){int n; double d; cin >> n >> d; bool ds=true; if(n==0&&d==0){ return 0; } for(int i=0;i<n;i++){ cin >> x[i]>> y[i]; a[i].l=x[i]-sqrt(d*d-y[i]*y[i]); a[i].r=x[i]+sqrt(d*d-y[i]*y[i]); if(y[i]>d){ ds=false; } } if(!ds){ cout <<-1 << endl; return 0; } sort(a,a+n,cmp); int ans=1; double note=a[0].r; for(int i=1;i<n;i++){ if(a[i].l>note){ ans++; note=a[i].r; } } cout << ans << endl; ans=0; return 0; } ```
by OItby @ 2020-01-11 19:30:06


@[Lycan!](/user/210122) 希望能对你有帮助
by OItby @ 2020-01-11 19:30:31


注意这里 ```cpp bool cmp(dao a,dao b){ return a.r<b.r; } ```
by OItby @ 2020-01-11 19:31:01


@[Lycan!](/user/210122) 解释可以参考题解第$4$面的第$1$篇题解,即我的……
by OItby @ 2020-01-11 19:33:47


@[AC黑洞](/user/141448) 谢谢你!!!
by coconutt_ @ 2020-01-11 20:38:07


|