|
#include <iostream> #include <algorithm> #include <cmath> #include <vector> using namespace std;
class MountainRoad { public: double findDistance(vector <int> start, vector <int> finish) { sort(start.begin(),start.end()); sort(finish.begin(),finish.end()); return sqrt(2.0)*(finish.back()-start.front()); } };
#include <iostream> using namespace std; class OddDivisors { public: long long findSum(int n) { long long sum=0LL; for(;n;n/=2) { long long k=(n+1)/2; sum+=k*k; } return sum; } };
#include <iostream> #include <cmath> #include <vector> using namespace std;
struct point { int x,y; point(int a,int b) { x=a; y=b; } }; vector<point>A,B;
vector<point> find(int a) { vector<point>v; int x,y; for(x=0;x*x<=a;x++) { y=int( sqrt((1.0*a-x*x)) ); if( (x*x+y*y)==a ) { v.push_back( point(x,y) ); v.push_back( point(x,-y) ); } } return v; }
class MaxTriangle { public: double calculateArea(int a,int b) { A=find(a); B=find(b); int i,j; double res=-1; for(i=0;i<A.size();i++) for(j=0;j<B.size();j++) { double area=abs((A[i].x*B[j].y-A[i].y*B[j].x))/2.0; if(area&&res<area) res=area; } return res;
} };
|