P2459 [SDOI2007] 立体分割 题解
Metaphysical · · 题解
P2459 [SDOI2007] 立体分割 题解
题目传送门 | Portals
P2459 [SDOI2007] 立体分割
题意归纳 | Title
把长宽高的分别为
题目分析 | Analyse
由于题目中说了:“每行
所以我们可以平均分长、宽或高。
解题思路 | Thinking
我写的是平均分高。
先用
- 左上点:
(0, 0, i \times s) - 右下点:
(x, y, (i - 1) \times s) 。
Code
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
using namespace std;
double x, y, z, n;
int main ()
{
scanf ("%lf%lf%lf%lf", &x, &y, &z, &n);
double s = z / n;
for (double i = 1; i <= n; i ++)
{
printf ("0 0 %.10lf ", (i - 1) * s);
printf ("%.10lf %.10lf %.10lf\n", x, y, i * s);
}
return 0;
}