📄 2497804_wa.cpp
字号:
#include <iostream>
#include <math.h>
using namespace std;
double p[8][2];
int main()
{
int i, j, k, cas = 1;
double tot, min, tmp;
int a, b, c, d, e, f, g, h;
while(cin>>a>>b>>c>>d>>e>>f>>g>>h)
{
if(a||b||c||d||e||f||g||h)
{
min = 10000000;
p[0][0] = a;p[0][1] = b;
p[1][0] = (a+c)/2.0;p[1][1] = (b+d)/2.0;
p[2][0] = c;p[2][1] = d;
p[3][0] = (c+e)/2.0;p[3][1] = (d+f)/2.0;
p[4][0] = e;p[4][1] = f;
p[5][0] = (e+g)/2.0,0;p[5][1] = (f+h)/2.0;
p[6][0] = g;p[6][1] = h;
p[7][0] = (g+a)/2.0;p[7][1] = (h+b)/2.0;
tot = 0;
for(i = 0; i < 7; i+=2)
tot += p[i][0]*p[(i+2)%8][1]-p[i][1]*p[(i+2)%8][0];
tot /= 2.0;
if(tot < 0)
tot *= -1;
for(i = 0; i < 8; i++)
{
for(j = i+1; j < 8; j++)
{
tmp = 0;
for(k = i; k < j; k++)
tmp += p[k][0]*p[k+1][1]-p[k][1]*p[k+1][0];
tmp += p[j][0]*p[i][1]-p[j][1]*p[i][0];
tmp /= 2;
if(tmp==4.75)
{
printf("%d %d\n",i,j);
return 1;
}
if(tmp<0)
tmp *= -1;
if(fabs(tot-tmp*2)<min)
min = fabs(tot-tmp*2);
}
}
printf("Case %d: %.3lf %.3lf\n",cas++,(tot-min)/2,(tot-min)/2+min);
}
else
break;
}
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -