Problem:
Score : 400 points

Problem Statement

Given are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.

Let a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \leq k \leq N):

There exists a non-negative integer p such that X= a_k \times (p+0.5).

Find the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Constraints

1 \leq N \leq 10^5

1 \leq M \leq 10^9

2 \leq a_i \leq 10^9

a_i is an even number.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
a_1 a_2 ... a_N

Output

Print the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Sample Input 1

2 50
6 10

Sample Output 1

2

15 = 6 \times 2.5

15 = 10 \times 1.5

45 = 6 \times 7.5

45 = 10 \times 4.5

Thus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.

Sample Input 2

3 100
14 22 40

Sample Output 2

0

The answer can be 0.

Sample Input 3

5 1000000000
6 6 2 6 2

Sample Output 3

166666667

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//

template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
void printArr(int *a, int len){for(int i=0; i<len; i++){if(i)cout << " ";cout << a[i];}cout << endl;}

//----------//

bool solve(vector<int> res, vector<int> a,int mid, int n){
    bool ok = true;
    rep(i, n){
        int tmp = mid - res[i];
        if(tmp % a[i] != 0){
            ok = false;
        }
    }
    return ok;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------/

    ll n, m;
    cin >> n >> m;
    vector<ll> v(n);
    rep(i, n){
        cin >> v[i];
    }

    vector<ll> res(n);

    rep(i, n){
        res[i] = v[i] * 0.5;
    }

    ll tmp1 = 1;
    rep(i, n){
        tmp1 = lcm(tmp1, res[i]);
    }
    //print(tmp1);

    vector<long double> tmp2(n);
    vector<long double> tmp3(n);
    rep(i, n){
        tmp2[i] = (long double)(tmp1) / (long double)(v[i]);
        if(tmp2[i] * 2 == ll(tmp2[i]) * 2){
            print(0);
            return 0;
        }
        //print(tmp2[i]);
    }

    ll tmp4 = 1;
    rep(i, n){
        tmp4 = lcm(tmp4, v[i]);
    }
    m -= tmp1;
    if(m < 0){
        //print(0);
        return 0;
    }

    ll ans = 0;
    ans = 1;
    ans += m / tmp4;
    cout << ans << endl;
    


    // int l = -1;
    // int r = 1e9+1;
    // while(r-l > 1){
    //     int mid = (r-l) / 2;
        
    // }
    
    
    return 0;
}