Cod sursa(job #1889026)

Utilizator kix101Sergiu Ciupe kix101 Data 22 februarie 2017 14:56:59
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <iostream>
#include <fstream>
using namespace std;
int n,k,s;
bool ok;
int main()
{
    ifstream f("fractii.in");
    ofstream g("fractii.out");
    f >> n;
    k=1;
    s=0;
    while (k<=n)
    {
        for (int i=1; i<=n; ++i)
        {
            bool ok = true;
            for (int j=2; j<=i; ++j)
                if (k%j==0 && i%j==0)
                {
                    ok = false;
                    break;
                }
        if (ok == true)
            s=s+1;
        }
        k=k+1;
    }
    cout << s;
    return 0;
}