Cod sursa(job #2206957)

Utilizator Alex_BubBuburuzan Alexandru Alex_Bub Data 24 mai 2018 16:59:46
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("dtcsu.in");
ofstream fout("dtcsu.out");

int v[5] = {2, 3, 5, 7, 11};

int main()
{
    int k, nr = 0;

    string s;

    getline(fin, s);

    fin >> k;

    fin.get();

    while(k--) {
        getline(fin, s);

        long long x = 0;

        for(string :: iterator it = s.begin(); it < s.end(); it++)
                x = x * 10 + (*it - '0');

        for(int i : v) {
            while(!(x % i)) x /= i;
        }

        if(x == 1) nr++;
    }

    fout << nr;

    fin.close();
    fout.close();

    return 0;
}