Cod sursa(job #907988)
| Utilizator | Data | 8 martie 2013 16:38:06 | |
|---|---|---|---|
| Problema | Dreptunghiuri | Scor | 70 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.63 kb |
#include<cstdio>
using namespace std;
int gcd( int a,int b ){
if(!b) return a;
return gcd( b, a%b );
}
int n,m,a,b,i,j,rez;
int main(){
freopen("dreptunghiuri.in","r",stdin);
freopen("dreptunghiuri.out","w",stdout);
scanf("%d %d", &n, &m );
for( a=1; a<n; ++a ){
for( b=0; b<m; ++b ){
for( i=1; i*a<n; ++i ){
for( j=1; i*a+b*j<n && i*b+j*a<m; ++j ){
if( gcd(i,j) == 1 ){
rez+=(n-(i*a+b*j))*(m-(b*i+a*j));
}
}
}
}
}
printf("%d\n",rez);
return 0;
}
