題目
int M[15];
unsigned long long nn,m;
unsigned long long gcd(unsigned long long a,unsigned long long b ){
return b == 0?a:gcd(b,a%b);
}
unsigned long long lcm(unsigned long long a,unsigned long long b){
return (a*b)/(gcd(a,b));
}
unsigned long long backtrace(int n,int w,unsigned long long d){
if(n == m){
return w*(nn/d);
}
return backtrace(n+1,w,d)+backtrace(n+1,-w,lcm(d,M[n]));
}
int main(int argc, char const* argv[])
{
while(scanf("%llu %llu",&nn,&m) != EOF){
for(int i = 0;i < m;i++) {
int mm;
scanf("%d",&mm);
M[i] = mm;
}
int ans = backtrace(0,1,1);
printf("%d\n",ans);
}
return 0;
}