import java.util.Scanner;
class Sub {
public static void main(String args[] ) throws Exception {
Scanner in = new Scanner(System.in);
int max= in.nextInt();
int cnt=0;
int flag=0;
int frnd=0;
int no = in.nextInt();
int arr[] = new int[no];
int div[] = new int[1000];
for(int i=0;i<no;i++)
arr[i]=in.nextInt();
int n=2;
int k=0;
while(max!=1){
if(max % n == 0){
div[k]=n;
k++;
cnt++;
max=max/n;
}
n++;
}
for(int i=0;i<no;i++){
for(int j=0;j<cnt;j++){
if(arr[i] % div[j]==0){
flag=1;
break;
}
else{
flag=0;
}
}
if(flag==1){
frnd++;
}
}
System.out.println(frnd);
}
}
class Sub {
public static void main(String args[] ) throws Exception {
Scanner in = new Scanner(System.in);
int max= in.nextInt();
int cnt=0;
int flag=0;
int frnd=0;
int no = in.nextInt();
int arr[] = new int[no];
int div[] = new int[1000];
for(int i=0;i<no;i++)
arr[i]=in.nextInt();
int n=2;
int k=0;
while(max!=1){
if(max % n == 0){
div[k]=n;
k++;
cnt++;
max=max/n;
}
n++;
}
for(int i=0;i<no;i++){
for(int j=0;j<cnt;j++){
if(arr[i] % div[j]==0){
flag=1;
break;
}
else{
flag=0;
}
}
if(flag==1){
frnd++;
}
}
System.out.println(frnd);
}
}
No comments:
Post a Comment