Cod sursa(job #919524)

Utilizator googolplexeGoogol googolplexe Data 19 martie 2013 18:29:48
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <fstream>
#include <iomanip>
 
using namespace std;
 
ifstream in("fractii.in");
ofstream out("fractii.out");
 
int n,result=0;
 
int divComun(int i,int j)
{
    if(i == 1 && j == 1)
        return 1;
    else if( i == 1 || j == 1)
        return 1;
    if(i == j)
        return 1;
    if(i % j == 0)
        return 1;
    if(j % i == 0)
        return 1;
    return 0;
}
 
void solve()
{
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n;j++)
        {
                result += divComun(i,j);
        }
}
 
int main()
{
    in >> n;
    in.close();
    solve();
    out << result;
    out.close();
    return 0;
}