cp_library

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

View the Project on GitHub downerkei/cp_library

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

Depends on

Code

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

#include <bits/stdc++.h>
using namespace std;

#include "../../math/is_prime.hpp"

int main() {
    int N;
    cin >> N;
    int ans = 0;
    while(N--) {
        int a;
        cin >> a;
        ans += is_prime(a);
    }
    cout << ans << endl;

    return 0;
}
#line 1 "verify/aoj/aoj_alds1_1_c.test.cpp"
#define PROBLEM "https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C"

#include <bits/stdc++.h>
using namespace std;

#line 1 "math/is_prime.hpp"
bool is_prime(long long p) {
    if(p < 2) return false;

    for(long long i = 2; i * i <= p; i++) {
        if(p % i == 0) return false;
    }

    return true;
}
#line 7 "verify/aoj/aoj_alds1_1_c.test.cpp"

int main() {
    int N;
    cin >> N;
    int ans = 0;
    while(N--) {
        int a;
        cin >> a;
        ans += is_prime(a);
    }
    cout << ans << endl;

    return 0;
}
Back to top page