#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C" #include <iostream> #include "Mylib/IO/input_tuples.cpp" #include "Mylib/Number/Prime/is_prime.cpp" namespace hl = haar_lib; int main() { int N; std::cin >> N; int ans = 0; for (auto [x] : hl::input_tuples<int>(N)) if (hl::is_prime(x)) ++ans; std::cout << ans << std::endl; return 0; }
#line 1 "test/aoj/ALDS1_1_C/main.test.cpp" #define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C" #include <iostream> #line 2 "Mylib/IO/input_tuples.cpp" #include <initializer_list> #line 4 "Mylib/IO/input_tuples.cpp" #include <tuple> #include <utility> #include <vector> #line 6 "Mylib/IO/input_tuple.cpp" namespace haar_lib { template <typename T, size_t... I> static void input_tuple_helper(std::istream &s, T &val, std::index_sequence<I...>) { (void) std::initializer_list<int>{(void(s >> std::get<I>(val)), 0)...}; } template <typename T, typename U> std::istream &operator>>(std::istream &s, std::pair<T, U> &value) { s >> value.first >> value.second; return s; } template <typename... Args> std::istream &operator>>(std::istream &s, std::tuple<Args...> &value) { input_tuple_helper(s, value, std::make_index_sequence<sizeof...(Args)>()); return s; } } // namespace haar_lib #line 8 "Mylib/IO/input_tuples.cpp" namespace haar_lib { template <typename... Args> class InputTuples { struct iter { using value_type = std::tuple<Args...>; value_type value; bool fetched = false; int N, c = 0; value_type operator*() { if (not fetched) { std::cin >> value; } return value; } void operator++() { ++c; fetched = false; } bool operator!=(iter &) const { return c < N; } iter(int N) : N(N) {} }; int N; public: InputTuples(int N) : N(N) {} iter begin() const { return iter(N); } iter end() const { return iter(N); } }; template <typename... Args> auto input_tuples(int N) { return InputTuples<Args...>(N); } } // namespace haar_lib #line 2 "Mylib/Number/Prime/is_prime.cpp" namespace haar_lib { constexpr bool is_prime(int n) { if (n <= 1) return false; for (int i = 2; i * i <= n; ++i) { if (n % i == 0) return false; } return true; } } // namespace haar_lib #line 6 "test/aoj/ALDS1_1_C/main.test.cpp" namespace hl = haar_lib; int main() { int N; std::cin >> N; int ans = 0; for (auto [x] : hl::input_tuples<int>(N)) if (hl::is_prime(x)) ++ans; std::cout << ans << std::endl; return 0; }