Pagini recente » Flux si cuplaj | Cod sursa (job #714856) | Cod sursa (job #491504) | Cod sursa (job #1143492) | Cod sursa (job #2491736)
#include <fstream>
#include <cmath>
using namespace std;
ifstream fin("dreptunghiuri.in");
ofstream fout("dreptunghiuri.out");
long long Sol, N, M;
bool FindC(int A, int l, int L)///C^2 - LC + A(l - A) = 0
{
int t = A * (l - A), delta, Ans = 0;
if(L * L >= 4 * t)
delta = sqrt(L * L - 4 * t);
else
return 0;
if(delta * delta == L * L - 4 * t)
{
double c1 = (L + delta) / 2, c2 = (L - delta) / 2;
if(0 < c1 && c1 < L && (L + delta) % 2 == 0)
Ans++;
if(0 < c2 && c2 < L && (L - delta) % 2 == 0)
Ans++;
return Ans;
}
return 0;
}
int Count(int l, int L)
{
int Ans = 0;
for(int A = 1; A < l; A++)
Ans += FindC(A, l, L);
return Ans + 1;
}
int main()
{
fin >> N >> M;
N--, M--;
for(int i = 1; i <= N; i++)
for(int j = 1; j <= M; j++)
{
Sol += Count(i, j) * (N - i + 1) * (M - j + 1);
}
fout << Sol << '\n';
fin.close();
fout.close();
return 0;
}