123456789101112131415161718192021222324252627282930313233 |
- #include <stdio.h>
- #include <math.h>
- #define PI 3.14159
- #define FENCE_COST_PER_METER 55
- #define PATH_COST_PER_SQUARE_METER 40
- #define PATH_WIDTH 3
- int main() {
- double pool_radius;
- double total_radius, fence_cost, path_cost;
- double pool_area, total_area, path_area;
- scanf("%lf", &pool_radius);
- // 计算总半径(游泳池半径 + 过道宽度)
- total_radius = pool_radius + PATH_WIDTH;
- // 计算栅栏造价
- fence_cost = 2 * PI * total_radius * FENCE_COST_PER_METER;
- // 计算过道面积和造价
- pool_area = PI * pool_radius * pool_radius;
- total_area = PI * total_radius * total_radius;
- path_area = total_area - pool_area;
- path_cost = path_area * PATH_COST_PER_SQUARE_METER;
- // 输出结果,保留整数
- printf("%d %d\n", (int)round(path_cost), (int)round(fence_cost));
- return 0;
- }
|