-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10394-Twin Primes.cpp
More file actions
50 lines (37 loc) · 819 Bytes
/
10394-Twin Primes.cpp
File metadata and controls
50 lines (37 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*----------------------|
/ Author : Ashraf Tasin |
/ Date : 11.09.18 |
/----------------------*/
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define all v.begin(),v.end()
#define M it=m.begin(),it!=m.end(),it++
#define db double
#define show for(int i=0;i<v.size();i++) cout << v[i] << " ";
#define eps .000000001
using namespace std;
bool prime[1000005];
int main()
{
vector <ll> v;
for(ll i=2;i*i<=1000000;i++)
{
if(prime[i]==0)
{
v.pb(i);
for(ll j=i*2;j<=1000000;j+=i) prime[j]=1;
}
}
ll x;
while(cin >> x)
{
if(x==0) break;
ll cnt=0;
int p=sqrt(x+1);
for(ll i=0;i<=p;i++) if(x%v[i]==0) cnt++;
cout << cnt << endl;
}
return 0;
}