Pagini recente » Cod sursa (job #1796878) | Cod sursa (job #2804325) | Cod sursa (job #469522) | Cod sursa (job #2325224) | Cod sursa (job #426296)
Cod sursa(job #426296)
//infoarena
#include<cstdio>
#include<iostream>
using namespace std;
FILE *f=fopen("dreptunghiuri.in","r");
FILE *g=fopen("dreptunghiuri.out","w");
int n,m,l1,l2;
long s;
int main()
{
fscanf(f,"%d %d",&m,&n);
for(l1=1;l1<n;l1++)
for(l2=1;l2<m;l2++)
{
s+=(n-l1)*(m-l2);//dreptunghiuri+patrate drepte
if(l1+l2<min(m,n))
if(l1!=l2) s+=2*(n-l1-l2)*(m-l1-l2);//dreptunghiuri oblice
else s+=(n-l1-l2)*(m-l1-l2);//patrate oblice
}
fprintf(g,"%ld",s);
return 0;
}