Pagini recente » Cod sursa (job #1346345) | Cod sursa (job #3031352) | Cod sursa (job #1658960) | Cod sursa (job #467082) | Cod sursa (job #1754425)
#include<fstream>
#include<cmath>
using namespace std;
int n, m, L, C, a, delta, x, r;
long long sol;
int d[405][405];
ifstream fin("dreptunghiuri.in");
ofstream fout("dreptunghiuri.out");
int main(){
fin>> n >> m;
n--;
m--;
for(L = 1; L <= n; L++){
for(C = 1; C <= m; C++){
for(a = 1; a < L; a++){
delta = C * C - 4 * (L * a - a * a);
if(delta < 0){
continue;
}
r = sqrt(delta * 1.0);
if(r * r != delta){
continue;
}
if(r == 0){
if(C % 2 == 0){
d[L][C]++;
}
}
else{
x = C - r;
if(x % 2 == 0 && x / 2 >= 1 && x / 2 < C){
d[L][C]++;
}
x = C + r;
if(x % 2 == 0 && x / 2 >= 1 && x / 2 < C){
d[L][C]++;
}
}
}
d[L][C]++;
}
}
for(L = 1; L <= n; L++){
for(C = 1; C <= m; C++){
sol += d[L][C] * 1LL * (n - L + 1) * (m - C + 1);
}
}
fout<< sol <<"\n";
return 0;
}