Pagini recente » Cod sursa (job #2964360) | Cod sursa (job #1643247) | Cod sursa (job #196154) | Cod sursa (job #1981679) | Cod sursa (job #1083282)
#include <fstream>
#include <cmath>
#define e 0.000001
using namespace std;
ifstream fin("dreptunghiuri.in");
ofstream fout("dreptunghiuri.out");
int n,m;
long long total;
bool aprox (double x)
{
if (x-int(x) < e || int(x)+1-x < e)
return 1;
return 0;
}
int main()
{
fin>>n>>m;
for (int X=1; X<n; ++X)
for (int Y=1; Y<m; ++Y)
{
int sum = 1;
for (int x=1; x < X; ++x)
{
double delta = sqrt(4*x*x - 4*X*x + Y*Y);
if (delta > e)
{
double root = (Y+delta)/2;
if (aprox(root) && 0 <= root && root <= Y)
{
++sum;
}
root = (Y-delta)/2;
if (aprox(root) && 0 <= root && root <= Y)
{
++sum;
}
}
else if (fabs(delta) < e)
{
if (Y%2==0 && 0 <= Y/2 && Y/2 <= Y)
++sum;
}
}
total += (n-X)*(m-Y)*sum;
}
fout<<total;
}