Pagini recente » Cod sursa (job #2370155) | Cod sursa (job #2622610) | Cod sursa (job #2164863) | Cod sursa (job #1908270) | Cod sursa (job #874687)
Cod sursa(job #874687)
#include <fstream>
using namespace std;
ifstream fin("reuniune.in"); ofstream fout("reuniune.out");
struct drept
{
long long x1, x2, y1, y2;
}
d[3];
long long a,p;
long long arie(drept a)
{
return (a.x2 - a.x1) * (a.y2 - a.y1);
}
long long per(drept a)
{
return 2 * (a.x2 - a.x1 + a.y2 - a.y1);
}
drept reun(drept a, drept b)
{
drept aux;
aux.x1 = max(a.x1 , b.x1);
aux.y1 = max(a.y1 , b.y1);
aux.x2 = min(a.x2 , b.x2);
aux.y2 = min(a.y2 , b.y2);
if (aux.x1 > aux.x2 || aux.y1 > aux.y2)
aux.x1 = aux.x2 = aux.y1 = aux.y2 = 0;
return(aux);
}
int main()
{
for (int i = 0; i < 3; i++)
fin >> d[i].x1 >> d[i].y1 >> d[i].x2 >> d[i].y2;
a = arie(d[0]) + arie(d[1]) + arie(d[2]) -
arie(reun(d[0], d[1])) - arie(reun(d[0], d[2])) - arie(reun(d[1] , d[2])) +
arie(reun(reun(d[0] , d[1]) , d[2]));
p = per(d[0]) + per(d[1]) + per(d[2]) -
per(reun(d[0], d[1])) - per(reun(d[0], d[2])) - per(reun(d[1],d[2])) +
per(reun(reun(d[0], d[1]), d[2]));
fout<<a<<" "<<p;
return(0);
}