Pagini recente » Cod sursa (job #2808283) | Cod sursa (job #1240291) | Cod sursa (job #1100996) | Cod sursa (job #2622234) | Cod sursa (job #1173922)
#include<fstream>
#include<iostream>
#include<cmath>
using namespace std;
ifstream f("dreptunghiuri.in"); ofstream g("dreptunghiuri.out");
int m,n,w,h,a,b,r,x,y,p;
int nr;
int main()
{ f>>m>>n;
for(h=1;h<m;h++)
for(w=1;w<n;w++)
{ p=(m-h)*(n-w);
nr+=p;
//cout<<"* "<<h<<' '<<w<<" dim "<<(m-h)*(n-w)<<'\n';
for(a=1;a<=h;a++)
{ b=h-a;
r=w*w-4*a*b;
if(r>0)
{ y=(int)sqrt((double)r);
if(y*y==r)
{ x=w-y;
if(!(x&1) && x>0)
{ //cout<<"**** "<<h<<' '<<w<<" a="<<a<<" c="<<x/2<<'\n';
nr+=p;
}
x=w+y;
if(!(x&1) && x/2<w)
{ //cout<<"**** "<<h<<' '<<w<<" a="<<a<<" c="<<x/2<<'\n';
nr+=p;
}
}
}
if(!r && !(w&1))
{ //cout<<"**** "<<h<<' '<<w<<" a="<<a<<" c="<<x/2<<'\n';
nr+=p;
}
}
}
g<<nr<<'\n';
g.close(); return 0;
}