Pagini recente » Cod sursa (job #702763) | Cod sursa (job #2283636) | Cod sursa (job #2262723) | Cod sursa (job #1183475) | Cod sursa (job #2429370)
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
FILE *f = fopen("dreptunghiuri.in","r");
FILE *g = fopen("dreptunghiuri.out","w");
int n,m;
int main(){
fscanf(f,"%d %d",&n,&m);
n--;m--;
long long ans = 0;
for(int h = 1;h <= n;h++){
for(int w = 1;w <= m;w++){
long long total = -3;
int deltaw_2 = (w % 2);
for(int deltah_2 = h % 2;deltah_2 <= h;deltah_2 += 2){
long long deltaw_p_2 = -1LL * h * h + 1LL * deltah_2 * deltah_2 + 1LL * w * w;
while(deltaw_2 < w && 1LL * deltaw_2 * deltaw_2 < deltaw_p_2){
deltaw_2 += 2;
}
if(1LL * deltaw_2 * deltaw_2 != deltaw_p_2){
continue;
}
total += (1 + (deltah_2 != 0)) * (1 + (deltaw_2 != 0));
}
ans += total * (n - h + 1) * (m - w + 1);
}
}
fprintf(g,"%lld\n",ans);
fclose(f);
fclose(g);
return 0;
}