#include using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template bool chmax(T &a, const T &b) { if(a bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- ll L; int N; ll A[1010]; int p2[1010],p3[1010]; const int prime_max = 2000000; int MU[prime_max+1]; int num[prime_max+1]; void mebius() { int i,j; for(i=1;i<=prime_max;i++) MU[i]=1, num[i]=i; for(int i=2;i<=prime_max;i++) if(num[i]==i) { for(j=i;j<=prime_max;j+=i) { int x=0; MU[j]=-MU[j]; while(num[j]%i==0) { x++; num[j]/=i; } if(x>=2) MU[j]=0; } } } ll G(ll L,int a,int b) { static ll memo[1<<20][2][2]; if(L==0) return 0; if(memo[L][a][b]) return memo[L][a][b]; ll ret=0; for(ll i=1;i*i<=L;i++) { ll k=0; if(i%2==0&&a) k=0; else if(i%3==0&&b) k=0; else { ll pat=L/(i*i); k=pat; if(a) k-=pat/2; if(b) k-=pat/3; if(a&&b) k+=pat/6; } ret+=MU[i]*k; } return ret; } void solve() { int i,j,k,l,r,x,y; string s; mebius(); cin>>L>>N; FOR(i,N) { cin>>A[i]; while(A[i]%2==0) { p2[i]++; A[i]/=2; } while(A[i]%3==0) { p3[i]++; A[i]/=3; } } ll ret=0; int mask; assert(N<=20); FOR(mask,1<=2||R3-L3>=2) continue; ll V=L>>R2; FOR(i,R3) V/=3; ll v=G(V,(R2-L2),(R3-L3)); ret+=p*v; } cout<