fork(1) download
  1. import java.util.*;
  2.  
  3. public class Main{
  4. public static long[] factors(long a){
  5.  
  6.  
  7. long[] b;
  8. b=new long[50];
  9. int count=0;
  10. for(long i=1L;i<=a/2;i++)
  11. if(a%i==0) b[count++]=i;
  12. return b;
  13. }
  14.  
  15. public static void main(String[] args) {
  16.  
  17. Scanner in=new Scanner(System.in);
  18.  
  19. int N=in.nextInt();
  20. long K=in.nextInt();
  21. long[] fact=factors(K);
  22. l1:
  23. for(int i=0;i<N;i++)
  24. {
  25. long num=in.nextInt();
  26. for(int j=0;j<fact.length;j++)
  27. if(num%fact[j]==0 && fact[j]!=1) {fact[j]=1;continue l1;}
  28.  
  29. }
  30. int result=0;
  31. for(int i=0;i<fact.length;i++)
  32. if(fact[i]!=1) ++result;
  33. System.out.println(result);
  34. }
  35. }
Success #stdin #stdout 0.06s 246080KB
stdin
1 12 3
stdout
48