Pagini recente » Cod sursa (job #3167217) | Cod sursa (job #3276888) | Cod sursa (job #320535) | Cod sursa (job #3207491) | Cod sursa (job #2638450)
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
const ld eps = 1e-8;
const ld PI = (ld) 2 * acos((ld) 0);
int X1, Y1, X2, Y2, i, n, j, p[1234], xr, m;
bitset<1234> a[1234];
ld angle1, angle2;
pair<ld, ld> A[1234];
vector<ld> ans, v, bisect;
ld get_angle(int x, int y) {
ld angle = atan2(y,x) * 180 / PI;
if (angle < 0) {
angle += 360;
}
return angle;
}
int main() {
freopen("laser.in", "r", stdin);
freopen("laser.out", "w", stdout);
function<bool(ld, ld, ld)> contain = [&] (ld x, ld y, ld z) {
if(y-x > 180)
return (z<x || z>y);
return (x<z && z<y);
};
cin>>n;
for(i=1; i<=n; ++i) {
cin>>X1>>Y1>>X2>>Y2;
angle1 = get_angle(X1, Y1);
angle2 = get_angle(X2, Y2);
if(angle1 > angle2)
swap(angle1, angle2);
A[i] = {angle1, angle2};
v.push_back(angle1);
v.push_back(angle2);
}
sort(v.begin(), v.end());
m = v.size();
for(i=0; i<m-1; ++i)
bisect.push_back( (v[i]+v[i+1])/2 );
bisect.push_back( ( v[0]+360 + v[m-1] )/2 );
if(bisect.back() > 360)
bisect.back() -= 360;
for(i=1; i<=n; ++i) {
for(j=1; j<=m; ++j)
a[i][j] = contain(A[i].first, A[i].second, bisect[j-1]);
cin>>xr;
a[i][m+1] = xr;
}
for(i=1; i<=n; ++i) {
for(j=1; j<=m+1; ++j)
if(a[i][j])
break;
if(j==m+2)
continue;
p[i] = j;
for(j=1; j<=n; ++j)
if(i!=j && a[j][p[i]])
a[j] ^= a[i];
}
for(i=1; i<=n; ++i)
if(p[i] && a[i][m+1])
ans.push_back(bisect[p[i]-1]);
cout<<(int) ans.size() << "\n";
for(auto x : ans) {
cout << fixed << setprecision(10) << x << "\n";
}
return 0;
}