Cod sursa(job #3372031)

Utilizator Vlad3218Garcea Vlad Vlad3218 Data 2 noiembrie 2026 12:51:36
Problema Dtcsu Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.62 kb
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <ctype.h>

using namespace std;

class InParser {
private:
	FILE *fin;
	char *buff;
	int sp;

	char read_ch() {
		++sp;
		if (sp == 4096) {
			sp = 0;
			fread(buff, 1, 4096, fin);
		}
		return buff[sp];
	}

public:
	InParser(const char* nume) {
		fin = fopen(nume, "r");
		buff = new char[4096]();
		sp = 4095;
	}

	InParser& operator >> (int &n) {
		char c;
		while (!isdigit(c = read_ch()) && c != '-');
		int sgn = 1;
		if (c == '-') {
			n = 0;
			sgn = -1;
		} else {
			n = c - '0';
		}
		while (isdigit(c = read_ch())) {
			n = 10 * n + c - '0';
		}
		n *= sgn;
		return *this;
	}

	InParser& operator >> (long long &n) {
		char c;
		n = 0;
		while (!isdigit(c = read_ch()) && c != '-');
		long long sgn = 1;
		if (c == '-') {
			n = 0;
			sgn = -1;
		} else {
			n = c - '0';
		}
		while (isdigit(c = read_ch())) {
			n = 10 * n + c - '0';
		}
		n *= sgn;
		return *this;
	}
};

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

const int MAX =  276997;
const int d[] = {2,3,5,7,11};

int q;
long long n,num;
int ans;

void input(){
    for (int i=1;i<=MAX;++i)
        fin >> num;
}

bool valid(long long n){
    for (int i=0;i<5;++i){
        int curr = d[i];
        while (n % curr == 0)
            n /= curr;
    }
    return !(n>1);
}

void solve(){
    fin >> q;
    for (int i=1;i<=q;++i){
        fin >> n;
        if (valid(n))
            ans++;
    }
}

void output(){
    fout << ans;
}

int main()
{
    input();
    solve();
    output();
    return 0;
}