Cod sursa(job #3353731)

Utilizator CosminaneBoac Mihai Cosmin Cosminane Data 10 mai 2026 17:56:34
Problema Rubarba Scor 30
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.36 kb
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
struct elem{
	double x, y;
};
double pi = 3.1415926535897932384626433832795;
elem v[100005];
elem rotate( elem a, double r ){
	double d, angle;
	elem ras;
	d = sqrt( a.x * a.x + a.y * a.y );
	angle = asin( a.x / d );
	angle += r / 180 * pi;
	ras.x = sin( angle ) * d;
	if( angle / pi * 180 > 90 ){
		ras.x = -ras.x;
	}
	ras.y = sqrt( d * d - ras.x * ras.x );
	//cout << angle << ' ' << angle / pi * 180 << ' ' << ras.x << ' ' << ras.y << '\n';
	return ras;
}
int main(){
	int n, i;
	double j, min_x, max_x, min_y, max_y, min_ras;
	elem a;
	ifstream fin( "rubarba.in" );
	ofstream fout( "rubarba.out" );
	fin >> n;
	for( i = 0; i < n; i++ ){
		fin >> v[i].x >> v[i].y;
	}
	min_ras = INT32_MAX / 2;
	for( j = 0; j < 90; j += 0.01 ){
		min_x = min_y = INT32_MAX / 2;
		max_x = max_y = -INT32_MAX / 2;
		for( i = 0; i < n; i++ ){
			a = rotate( v[i], j );
			min_x = min( a.x, min_x );
			max_x = max( a.x, max_x );
			min_y = min( a.y, min_y );
			max_y = max( a.y, max_y );
		}
		min_ras = min( ( max_x - min_x ) * ( max_y - min_y ), min_ras );
		//break;
	}
	//cout << sin( ( double ) 90 / 180 * pi ) << '\n';
	//cout << asin( -1 ) / pi * 180;
	fout << setprecision( 2 ) << fixed << ( double ) ( ( int ) ( min_ras * 100 ) ) / 100;
	return 0;
}