rcpl

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub ruthen71/rcpl

:heavy_check_mark: verify/aoj_alds1/aoj_alds1_1_c.test.cpp

Depends on

Code

#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C"

#include <bits/stdc++.h>

#include "math/prime_table.hpp"

int main() {
    auto pt = prime_table(100000000);
    int n;
    std::cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        ans += pt[a];
    }
    std::cout << ans << '\n';
    return 0;
}
#line 1 "verify/aoj_alds1/aoj_alds1_1_c.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C"

#include <bits/stdc++.h>

#line 2 "math/prime_table.hpp"

std::vector<bool> prime_table(int n) {
    std::vector<bool> res(n + 1, true);
    if (n >= 0) res[0] = false;
    if (n >= 1) res[1] = false;
    for (int p = 2; p * p <= n; p++) {
        if (!res[p]) continue;
        for (int i = p * p; i <= n; i += p) {
            res[i] = false;
        }
    }
    return res;
}
#line 6 "verify/aoj_alds1/aoj_alds1_1_c.test.cpp"

int main() {
    auto pt = prime_table(100000000);
    int n;
    std::cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        ans += pt[a];
    }
    std::cout << ans << '\n';
    return 0;
}
Back to top page