Ural_1333. Genie Bomber 2
2011-10-29 17:11
218 查看
/*从昨晚开始想这题,看到队友有人1Y很快过了,备受打击。然后就一直考虑各种情 况,各种debug,都没能过。下午另一个队友也很快1Y了,很纳闷,问了一下,搜的解题 报告,思路是把1*1的方格分成1000*1000个离散的点,然后统计被圆覆盖的点的个数。这 个方法实在有点。。。无语。发现有的人一不会就搜解题报告,没意思,宁愿浪费时间也 不那样做,这题算是间接的看得解题报告吧。检讨!*/ //Copy thinking code: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> using namespace std; const int N = 11; struct circle{ double x; double y; double r; }c ; int n; bool in_this_circle(int i, double a, double b){ double tmp = sqrt((a-c[i].x)*(a-c[i].x) + (b-c[i].y)*(b-c[i].y)); return tmp > c[i].r ? 0 : 1; } bool in_circle(double i, double j){ for(int x = 0; x < n; x++) if(in_this_circle(x, i, j)) return true; return false; } int main(){ //freopen("data.in", "r", stdin); int k, cnt; double i, j; scanf("%d", &n); for(k = 0; k < n; k++) scanf("%lf%lf%lf", &c[k].x, &c[k].y, &c[k].r); for(cnt = 0, i = 0; i <= 1; i += 0.001) for(j = 0; j <= 1; j += 0.001) if(in_circle(i, j)) cnt++; printf("%lf\n", double(cnt)/(1000*1000)*100); return 0; }
相关文章推荐
- URAL 2014 Zhenya moves from parents 线段树
- ural 2018. The Debut Album 滚动数组dp
- BZOJ1397 Ural 1486 Equal squares
- URAL 1057 Amount of Degrees (数位DP)
- URAL 2000. Grand Theft Array V(贪心啊)
- URAL 1005 Stone Pile
- URAL 1820 Ural Steaks (贪心)
- URAL 1209. 1, 10, 100, 1000... (规律 + 二分)
- URAL 1298. Knight(DFS啊 )
- URAL 1110. Power
- URAL 1196. History Exam (二分)
- URAL 1731. Dill(数学啊 )
- URAL 1825. Ifrit Bomber 2 两圆的面积并
- POJ 2366 (URAL 1021)Sacrament of the Sum
- URAL - 1586 Threeprime Numbers
- 【状压】 URAL 1500 Pass Licenses
- URAL 1057 数位DP
- URAL_1789_Searching for the Dodecahedron_机智
- ural 1225 Flags
- 递推DP URAL 1119 Metro