Cod sursa(job #936409)

Utilizator mihai995mihai995 mihai995 Data 6 aprilie 2013 23:14:26
Problema Dreptunghiuri Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <fstream>
using namespace std;

ifstream in("dreptunghiuri.in");
ofstream out("dreptunghiuri.out");

inline int cmmdc(int x, int y){
    return y ? cmmdc(y, x % y) : x;
}

int main(){
    int n, m;
    long long rez = 0;

    in >> n >> m;

    for (int i = 1 ; i <= n ; i++)
        for (int j = 1 ; j <= m ; j++)
            rez += (n - i) * (m - j) * cmmdc(i, j);

    out << rez << "\n";

    return 0;
}