Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int v[1000000], n;
- void read(int n, int v[])
- {
- if (n > -1)
- {
- read(n - 1, v);
- cin >> v[n];
- }
- }
- int isPrime(int x, int d)
- {
- if (x == 1)
- return 0;
- if (d == 1)
- return 1;
- if (x % d == 0)
- return 0;
- return isPrime(x, d - 1);
- }
- int cnt(int n, int v[])
- {
- if (n == -1 )
- return 0;
- if (isPrime(v[n], v[n] / 2))
- return cnt(n - 1, v) + 1;
- return cnt(n - 1, v);
- }
- int main()
- {
- int n;
- cin >> n;
- read(n - 1, v);
- cout << cnt(n - 1, v);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement