Problem:
一般化うるう年
通常，西暦
x
年がうるう年か否かは以下のように定義されている．
x
が 400 の倍数であれば，うるう年である．
そうでないとき，
x
が 100 の倍数であれば，うるう年ではない．
そうでないとき，
x
が 4 の倍数であれば，うるう年である．
そうでないとき，うるう年ではない．
これは次のように一般化できる．ある数列
A
1
, ..., A
n
について，西暦
x
年が "一般化うるう年" であるか否かを以下のように定義する．
x
が
A
i
の倍数であるような最小の
i
(
1 ≤ i ≤ n
) について，
i
が奇数であれば一般化うるう年であり，偶数であれば一般化うるう年ではない．
そのような
i
が存在しないとき，
n
が奇数であれば一般化うるう年ではなく，偶数であれば一般化うるう年である．
例えば
A = [400, 100, 4]
のとき，この
A
に対する一般化うるう年は通常のうるう年と等価になる．
数列
A
1
, ..., A
n
と正の整数
l, r
が与えられるので．
l ≤ x ≤ r
なる正の整数
x
のうち，西暦
x
年が
A
に対する一般化うるう年であるような
x
の個数を答えよ．
Input
入力は最大で 50 個のデータセットからなる．各データセットは次の形式で表される．
n
l
r
A
1
A
2
...
A
n
整数
n
は
1 ≤ n ≤ 50
を満たす．整数
l,r
は
1 ≤ l ≤ r ≤ 4000
を満たす．各
i
に対し整数
A
i
は
1 ≤ A
i
≤ 4000
を満たす．
入力の終わりは 3 つのゼロからなる行で表される．
Output
各データセットについて，答えを 1 行で出力せよ．
Sample Input
3 1988 2014
400
100
4
1 1000 1999
1
2 1111 3333
2
2
6 2000 3000
5
7
11
9
3
13
0 0 0
Output for the Sample Input
7
1000
2223
785

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define rep(i, a, n) for(ll i = a; i < n; i++)
#define rrep(i, a, n) for(ll i = a; i >= n; i--)
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
constexpr int IINF = 1001001001;
constexpr ll INF = 1LL<<60;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}


ll gcd(ll a, ll b){
    if(a%b == 0){
      return b;
    }else{
      return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a*b / gcd(a, b);
}

ll powMod(ll x, ll n) {
    if (n == 0) return 1 % MOD;
    ll val = powMod(x, n / 2);
    val *= val;
    val %= MOD;
    if (n % 2 == 1) val *= x;
    return val % MOD;
}

int main() {
    while(true){
        ll n, l, r; cin >> n >> l >> r;
        if(n == 0) break;
        vector<ll> a(n);
        rep(i,0,n) cin >> a[i];
        ll ans = 0;
        rep(i,l,r+1){
            ll cnt = 0;
            rep(j,0,n){
                if(i%a[j] == 0){
                    break;
                }
                cnt++;
            }
            if(cnt%2 == 0) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3328
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using int128 = __int128;
using State = string::const_iterator;
class ParseError {};
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define reps(i, l, r) for(ll i = (l); i < (r); i++)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl "\n";
const ll INF = LLONG_MAX / 4;
const ld inf = numeric_limits<long double>::max() / (ld)4;
const ll mod1 = 1000000007;
const ll mod2 = 998244353;
const ld pi = 3.1415926535897;
const ll Hash = (1ll << 61) - 1;
ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
ll dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T>
bool chmax(T &a, const T& b) {
	if (a < b) { a = b; return true; }
	return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
	if (a > b) { a = b; return true; }
	return false;
}
bool solve() {
	ll N, L, R; cin >> N >> L >> R;
	if (N == 0 && L == 0 && R == 0) return false;
	vector<ll>A(N);
	rep(i, N) cin >> A[i];
	ll ans = 0;
	for (ll i = L; i <= R; i++) {
		ll pos = 0;
		while (pos < N && i % A[pos] != 0) pos++;
		if (pos != N && pos % 2 == 0) ans++;
		else if (pos == N && N % 2 == 0) ans++;
	}
	cout << ans << endl;
	return true;
}
int main() {
	bool check = true;
	while (check) {
		check = solve();
	}
}
accuracy: 1
time_ms: 10
memory_kb: 3324
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using a2 = array<ll, 2>;
using a3 = array<ll, 3>;

template <typename A> void chmin(A &l, const A &r) {
    if(r < l)
        l = r;
}
template <typename A> void chmax(A &l, const A &r) {
    if(l < r)
        l = r;
}

ll mod = 998244353;

ll n, l, r;
vector<ll> v;
void input() {
    cin >> n >> l >> r;
    v.resize(n);
    for(auto &x : v) {
        cin >> x;
    }
    v.push_back(1);
}

void solve() {
    ll ans = 0;
    for(int i = l; i <= r; i++) {
        for(int j = 0; j < v.size(); j++) {
            if(i % v[j] == 0) {
                if(j % 2 == 0) {
                    ans++;
                }
                break;
            }
        }
    }
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    while(1) {
        input();
        if(n == 0)
            break;
        solve();
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3360
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; ++i)

int main() {
    while(1){
        ll n,l,r;
        cin >> n >> l >> r;
        if(n == 0)break;
        vector<ll> a(n);
        rep(i, n){
            cin >> a[i];
        }
        ll ans = 0;
        for(ll i = l; i <= r; i++){
            bool flag = false;
            rep(j, n){
                if(i % a[j] == 0){
                    if((j + 1) % 2 == 1)ans++;
                    flag = true;
                    break;
                }
            }
            if(!flag){
                if(n % 2 == 0)ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3436
final_rank: 16

code_snippet: #line 1 "2018JAGB.cpp"
#include <bits/stdc++.h>
#line 1 "/home/ardririy/repos/cp-libs/libraries-cpp/input.hpp"


#line 6 "/home/ardririy/repos/cp-libs/libraries-cpp/input.hpp"
using namespace std;
vector<long long> i64_vec_IN(int n) {vector<long long> res(n); for(int i=0; i<n; i++) { cin >> res[i]; } return res; }
vector<string> str_vec_IN(int n) { vector<string> res(n); for(int i=0; i<n; i++) { cin >> res[i]; } return res; }
vector<vector<int>> graph_IN(int n, int m) { vector<vector<int>> g(n); int u, v; for(int i=0; i<m; i++) { cin >> u >> v; u--; v--; g[u].emplace_back(v); g[v].emplace_back(u); } return g; }
vector<vector<pair<int, long long>>> weighted_graph_IN(int n, int m) { vector<vector<pair<int, long long>>> g(n); int u, v; long long w; for(int i=0; i<m; i++) { cin >> u >> v >> w; u--; v--; g[u].push_back({v, w}); g[v].push_back({u, w}); } return g; }


#line 3 "2018JAGB.cpp"

using namespace std;

// using namespace atcoder;

#ifdef ADRY
#include <dbg.h>
#else
// DO NOTHING
#define dbg(x)
#endif


#define all(v) v.begin(),v.end()
#define resort(v) sort(v.rbegin(),v.rend())
using ll = long long;
using ull = unsigned long long;
using vll=vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,ll>;
using vp=vector<pair<ll, ll>>;
using djks=priority_queue<P, vp, greater<P>>;

const int inf=1ll<<30;
#define mod10 (ll)1e9+7
#define mod99 (ll)998244353
const double PI = acos(-1);

#define rep(i,n) for (ll i=0;i<(n);++i)
#define per(i,n) for(ll i=(n)-1;i>=0;--i)
#define rep2(i,a,n) for (ll i=(a);i<(n);++i)
#define per2(i,a,n) for (ll i=(n)-1;i>=(a);--i)


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

ll dx[] = {1, 0, -1, 0, -1, 1, -1, 1};
ll dy[] = {0, 1, 0, -1, -1, 1, 1, -1};


int solve(){
    int n, l, r; cin >> n >> l >> r;
    if(n==0) return 1;
    auto a = i64_vec_IN(n);
    ll ans = 0;
    rep2(x,l,r+1) {
        bool flag = false;
        rep(i,n) {
            if(x%a[i]==0) {
                if(i%2==0) {
                    ans ++;
                }
                flag = true;
                break;
            }
        }
        if(!flag && n%2==0) ans++;
    }
    cout << ans << '\n';
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(!solve());
}
accuracy: 1
time_ms: 10
memory_kb: 3368
final_rank: 13

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,l,r) for(ll i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(A) A.begin(),A.end()
int main(){
    while(1){
        ll N,L,R;cin>>N>>L>>R;
        if(N==0)break;
        vector<int>A(N);
        REP(i,N)cin>>A[i];
        ll ans=0;
        FOR(x,L,R+1){
            ll t=0;
            while(t<N&&x%A[t])t++;
            if(N==t)ans+=1-N%2;
            else ans+=(t%2==0);
        }
        cout<<ans<<endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3352
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define all(v) v.begin(), v.end()
#define ll long
#define ld long double
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;

int main() {
    while (true) {
        ll n, l, r;
        cin >> n >> l >> r;
        if (n + l + r == 0) return 0;
        vl a(n);
        for (int i = 0; i < n;i++)cin >> a[i];
        ll ans = 0;
        for (int i = l; i <= r;i++){
            bool done = false;
            for (int j = 0; j < n; j++) {
                if (i%a[j] == 0) {
                    if (j % 2 == 0) ans++;
                    done = true;
                }
				if(done)break;
            }
            if (!done & n % 2 == 0) ans++;
        }
        cout << ans << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3144
final_rank: 1

code_snippet: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<long long>;
using vvl = vector<vector<long long>>; using vs = vector<string>;
using pl = pair<long long, long long>;
template <typename T> inline bool chmin(T& a, const T& b) {bool compare = a > b; if (a > b) a = b; return compare;}
template <typename T> inline bool chmax(T& a, const T& b) {bool compare = a < b; if (a < b) a = b; return compare;}
template<class T>using rp_queue=priority_queue<T,vector<T>,greater<T>>;
template <typename T> T gcd(T a, T b) {if (b == 0)return a; else return gcd(b, a % b);}
template <typename T> inline T lcm(T a, T b) {return a /gcd(a, b)*b;}
const ll INF = 1LL << 60;
const ld PI = acos(-1);
template <class OStream, class T> OStream &operator<<(OStream &os, const std::vector<T> &vec);
template <class OStream, class T, size_t sz> OStream &operator<<(OStream &os, const std::array<T, sz> &arr);
template <class OStream, class T, class TH> OStream &operator<<(OStream &os, const std::unordered_set<T, TH> &vec);
template <class OStream, class T, class U> OStream &operator<<(OStream &os, const pair<T, U> &pa);
template <class OStream, class T> OStream &operator<<(OStream &os, const std::deque<T> &vec);
template <class OStream, class T> OStream &operator<<(OStream &os, const std::set<T> &vec);
template <class OStream, class T> OStream &operator<<(OStream &os, const std::multiset<T> &vec);
template <class OStream, class T> OStream &operator<<(OStream &os, const std::unordered_multiset<T> &vec);
template <class OStream, class T, class U> OStream &operator<<(OStream &os, const std::pair<T, U> &pa);
template <class OStream, class TK, class TV> OStream &operator<<(OStream &os, const std::map<TK, TV> &mp);
template <class OStream, class TK, class TV, class TH> OStream &operator<<(OStream &os, const std::unordered_map<TK, TV, TH> &mp);
template <class OStream, class... T> OStream &operator<<(OStream &os, const std::tuple<T...> &tpl);
 
template <class OStream, class T> OStream &operator<<(OStream &os, const std::vector<T> &vec) { os << '['; for (auto v : vec) os << v << ','; os << ']'; return os; }
template <class OStream, class T, size_t sz> OStream &operator<<(OStream &os, const std::array<T, sz> &arr) { os << '['; for (auto v : arr) os << v << ','; os << ']'; return os; }
template <class... T> std::istream &operator>>(std::istream &is, std::tuple<T...> &tpl) { std::apply([&is](auto &&... args) { ((is >> args), ...);}, tpl); return is; }
template <class OStream, class... T> OStream &operator<<(OStream &os, const std::tuple<T...> &tpl) { os << '('; std::apply([&os](auto &&... args) { ((os << args << ','), ...);}, tpl); return os << ')'; }
template <class OStream, class T, class TH> OStream &operator<<(OStream &os, const std::unordered_set<T, TH> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <class OStream, class T> OStream &operator<<(OStream &os, const std::deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ','; os << ']'; return os; }
template <class OStream, class T> OStream &operator<<(OStream &os, const std::set<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <class OStream, class T> OStream &operator<<(OStream &os, const std::multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <class OStream, class T> OStream &operator<<(OStream &os, const std::unordered_multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <class OStream, class T, class U> OStream &operator<<(OStream &os, const std::pair<T, U> &pa) { return os << '(' << pa.first << ',' << pa.second << ')'; }
template <class OStream, class TK, class TV> OStream &operator<<(OStream &os, const std::map<TK, TV> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
template <class OStream, class TK, class TV, class TH> OStream &operator<<(OStream &os, const std::unordered_map<TK, TV, TH> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
#ifdef LOCAL
const string COLOR_RESET = "\033[0m", BRIGHT_GREEN = "\033[1;32m", BRIGHT_RED = "\033[1;31m", BRIGHT_CYAN = "\033[1;36m", NORMAL_CROSSED = "\033[0;9;37m", RED_BACKGROUND = "\033[1;41m", NORMAL_FAINT = "\033[0;2m";
#define dbg(x) std::cerr << BRIGHT_CYAN << #x << COLOR_RESET << " = " << (x) << NORMAL_FAINT << " (L" << __LINE__ << ") " << __FILE__ << COLOR_RESET << std::endl
#define dbgif(cond, x) ((cond) ? std::cerr << BRIGHT_CYAN << #x << COLOR_RESET << " = " << (x) << NORMAL_FAINT << " (L" << __LINE__ << ") " << __FILE__ << COLOR_RESET << std::endl : std::cerr)
#else
#define dbg(x) ((void)0)
#define dbgif(cond, x) ((void)0)
#endif
void solve();
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  int num_tc = 1;
  //cin >> num_tc;
  rep(tc,num_tc){
    //cout << "Case #" << tc+1 << ": " ;// << endl;
    solve();
  }
}
//見切り発車で実装しては行けない．頭の中でコードが完全に出来上がるまで書き始めるな．
//オーバーフローしているか確認する
//小さいケースで動いているかを確認する。
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
void solve(){
  while(true){
    int n,l,r;cin>>n>>l>>r;
    if(n==0&&l==0&&r==0)return;
    vl A(n);rep(i,n)cin>>A[i];
    ll ans = 0;
    for(int x=l;x<=r;x++){
      int idx = -1;
      rep(i,n){
        if(x%A[i]==0){
          idx = i;
          break;
        }
      }
      if(idx>=0&&idx%2==0)ans++;
      else if(idx==-1&&n%2==0)ans++;
    }
    cout<<ans<<endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3468
final_rank: 19

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e9 + 1001010;
const ll llINF = (long long)4e18 + 22000020;
const string endn = "\n";
template <class T> inline auto vector2(size_t i, size_t j, const T &init = T()) {return vector(i, vector<T>(j, init));}
const string ELEM_SEPARATION = " ", VEC_SEPARATION = endn;
template<class T> istream& operator >>(istream &i, vector<T> &A) {for(auto &I : A) {i >> I;} return i;}
template<class T> ostream& operator <<(ostream &o, const vector<T> &A) {int i=A.size(); for(const auto &I : A){o << I << (--i ? ELEM_SEPARATION : "");} return o;}
template<class T> ostream& operator <<(ostream &o, const vector<vector<T>> &A) {int i=A.size(); for(const auto &I : A){o << I << (--i ? VEC_SEPARATION : "");} return o;}
template<class T> vector<T>& operator ++(vector<T> &A, int n) {for(auto &I : A) {I++;} return A;}
template<class T> vector<T>& operator --(vector<T> &A, int n) {for(auto &I : A) {I--;} return A;}
template<class T, class U> bool chmax(T &a, const U &b) {return ((a < b) ? (a = b, true) : false);}
template<class T, class U> bool chmin(T &a, const U &b) {return ((a > b) ? (a = b, true) : false);}
ll floor(ll a, ll b){if (b < 0) a = -a, b = -b; if(a >= 0) return a / b; else return (a + 1) / b - 1;}
ll ceil(ll a, ll b){if (b < 0) a = -a, b = -b; if(a > 0) return (a - 1) / b + 1; else return a / b;}
ll bit(unsigned long long val, unsigned long long digit){return (val >> digit) & 1;}
#ifdef DEBUG
#include <debug_slephy.cpp>
#else
#define debug(...)
#endif
// ================================== ここまでテンプレ ==================================

void solve(){
    ll n, l, r; cin >> n >> l >> r;
    if(n == 0) exit(0);
    vector<ll> a(n); cin >> a;
    a.emplace_back(1);
    n++;

    ll ans = 0;
    for(ll x = l; x <= r; x++){
        for(int i = 0; i < a.size(); i++){
            if(x % a[i] == 0){
                if(i%2 == 0) ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    while(true) solve();
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3476
final_rank: 20

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
using PP = pair<int, P>;
using PLL = pair<ll, ll>;
using PPLL = pair<ll, PLL>;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, a, b) for (ll i = a; i <= b; ++i)
#define all(v) v.begin(), v.end()
constexpr ll INF = 1001001001001001001LL;
constexpr int INF32 = 1001001001;
constexpr ll MOD = 998244353;
constexpr ll MOD107 = 1000000007;

// Graph /////////////////////////////////////////////////////////
template <class T> struct Edge {
    int from;
    int to;
    T val;

    Edge() : from(-1), to(-1), val(1) {}
    Edge(const int &i) {
        from = -1, to = i;
        val = 1;
    }
    Edge(int from, int to) : from(from), to(to), val(1) {}
    Edge(int from, int to, T val) : from(from), to(to), val(val) {}
    bool operator==(const Edge &e) const {
        return from == e.from && to == e.to && val == e.val;
    }
    bool operator!=(const Edge &e) const {
        return from != e.from || to != e.to || val != e.val;
    }

    operator int() const { return to; }

    friend ostream &operator<<(ostream &os, const Edge &e) {
        os << e.from << " -> " << e.to << " : " << e.val;
        return os;
    }
};
template <class T> using Graph = vector<vector<Edge<T>>>;
//////////////////////////////////////////////////////////////////

// Math //////////////////////////////////////////////////////////
ll pow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1) res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll pow(ll a, ll b, ll mod) {
    if (b < 0) return pow(a, mod - 1 + b, mod);
    ll res = 1;
    while (b > 0) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}
/**
 * @brief 法がmodのときのaの逆元を求める
 * @remark modが素数のときのみ有効
 * @remark
 * aとmodが互いに素でなければいけない(割り算の代わりに使う場合は、気にしなくても大丈夫)
 * @details a^(p-1) ≡ 1 mod p -[両辺にa^(-1)を掛ける]-> a^(p-2) ≡ a^(-1) mod p
 * @param a 逆元を求めたい値
 * @param mod 法
 * @return ll aの逆元
 */
ll inv(ll a, ll mod) { return pow(a, mod - 2, mod); }

ll nCrDP[67][67];
ll nCr(ll n, ll r) {
    if (nCrDP[n][r] != 0) return nCrDP[n][r];
    if (r == 0 || n == r) return 1;
    return nCrDP[n][r] = nCr(n - 1, r - 1) + nCr(n - 1, r);
}
ll nHr(ll n, ll r) { return nCr(n + r - 1, r); }

unordered_map<ll, vector<ll>> fact, invfact;
ll nCr(ll n, ll r, ll mod) {
    if (fact.count(mod) == 0 || fact[mod].size() <= max(n, r)) {
        const ll size = max(500000LL, max(n, r));
        fact[mod] = vector<ll>(size + 1, 0);
        invfact[mod] = vector<ll>(size + 1, 0);
        fact[mod][0] = 1;
        for (int i = 0; i < size; ++i)
            fact[mod][i + 1] = fact[mod][i] * (i + 1) % mod;
        invfact[mod][size] = inv(fact[mod][size], mod);
        for (int i = size - 1; i >= 0; --i)
            invfact[mod][i] = invfact[mod][i + 1] * (i + 1) % mod;
    }
    return fact[mod][n] * invfact[mod][r] % mod * invfact[mod][n - r] % mod;
}
ll nHr(ll n, ll r, ll mod) { return nCr(n + r - 1, r, mod); }
//////////////////////////////////////////////////////////////////

// Linear Algebra ////////////////////////////////////////////////
const double Rad2Deg = 180.0 / M_PI;
const double Deg2Rad = M_PI / 180.0;
//////////////////////////////////////////////////////////////////

int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

template <class T> inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
    for (size_t i = 0; i < v.size(); ++i) {
        os << v[i];
        if (i != v.size() - 1) os << " ";
    }
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<vector<T>> &vv) {
    for (size_t i = 0; i < vv.size(); ++i) {
        os << vv[i];
        if (i != vv.size() - 1) os << "\n";
    }
    return os;
}

struct phash {
    inline size_t operator()(const pair<ll, ll> &p) const {
        const auto h1 = hash<ll>()(p.first);
        const auto h2 = hash<ll>()(p.second);
        return h1 + h2 * 12345;
    }
};

int solve() {
    ll n, l, r;
    cin >> n >> l >> r;
    if (n == 0) return 1;

    vll a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;
    loop(i, l, r) {
        bool found = false;
        rep(j, n) {
            if (i % a[j] == 0) {
                if ((j + 1) % 2 == 1) {
                    ans++;
                    found = true;
                    break;
                } else {
                    found = true;
                    break;
                }
            }
        }

        if (!found && n % 2 == 0) ans++;
    }

    cout << ans << endl;

    return 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    while (!solve()) {
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3384
final_rank: 15

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;
struct SetupIO {
    SetupIO() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout << fixed << setprecision(30);
    }
} setup_io;

bool u(ll x, const vector<ll> &a, ll n) {
    rep(i,1,n+1){
        if(x%a[i] == 0){
            if(i%2 == 1){
                return true;
            }else{
                return false;
            }
        }
    }
    if(n % 2 == 1){
        return false;
    }else{
        return true;
    }
}
int main(void) {
    while(1){
        ll n,l,r;cin>>n>>l>>r;
        if(n == 0)break;
        vector<ll> a(n+1);rep(i,1,n+1)cin>>a[i];
        ll ans = 0;
        rep(i,l,r+1){
            if(u(i, a, n)){
                ans += 1;
            }
        }
        cout << ans << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3264
final_rank: 4

code_snippet: #include<bits/stdc++.h>
using namespace std;

using ll = long long;
using vll= vector<ll>;
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<n;i++)

bool solve(){
    ll N,l,r;cin>>N>>l>>r;
    if(N==0&&l==0&&r==0) return 0;

    vll A(N);rep(i,N) cin>>A[i];
    ll ans=0;
    rep(i,r+1){
        if(i<l)continue;
        rep(j,N){
            if(i%A[j]==0){
                if(j%2==0) ans++;
     
                break;
            }
            if(j==N-1){
                if(N%2==0) ans++;
            }
        }
    }
    cout << ans << endl;
    return 1;
}

int main(){
    while(solve());
}
accuracy: 1
time_ms: 10
memory_kb: 3364
final_rank: 12

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,t) for (int i = (int)(s); i < (int)(t); ++i)
#define all(x) (x).begin(), (x).end()

#define vll vector<ll>

int main(){
    while(true){
        ll n,l,r;
        cin>>n>>l>>r;
        if(n==0)break;
        vll a(n);
        rep(i,0,n){
            cin>>a[i];
        }
        ll ans = 0;
        rep(x,l,r+1){
            ll flag = -1;
            rep(i,0,n){
                if(x % a[i] == 0){
                    if(i%2 == 0) flag = 1;
                    else flag = 0;
                    break;
                }
            }
            if(flag == -1){
                if(n%2 == 1) flag = 0;
                else flag = 1;
            }
            if(flag == 1) ans ++;
        }
        cout << ans << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3348
final_rank: 7

code_snippet: #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, s, e) for (ll i = s; i < e; i++)
using namespace std;
using ll = long long;

int solve() {
  ll n, l, r;
  cin >> n >> l >> r;
  if (!n) return 0;
  vector<ll> a(n);
  rep(i, 0, n) cin >> a[i];
  ll cnt = 0;
  rep(x, l, r + 1) {
    bool f = true;
    rep(i, 0, n) {
      if (x % a[i]) continue;
      if ((i + 1) % 2) {
        cnt++;
      }
      f = false;
      break;
    }
    if (f && n % 2 == 0) cnt++;
  }
  cout << cnt << endl;
  return 1;
}

int main() {
  while (solve())
    ;
}
accuracy: 1
time_ms: 10
memory_kb: 3444
final_rank: 17

code_snippet: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>

using namespace std;
typedef long long int ll;
const ll INF = ((ll)1 << 60);

bool check(ll x, vector<ll>& a) {
	ll n = a.size();
	for (ll i = 0; i < n; ++i) {
		if (x%a[i] == 0) {
			return i % 2;
		}
	}
	return n % 2;
}

int main() {
	while (1) {
		ll n, l, r;
		cin >> n >> l >> r;
		if (n == 0)break;
		vector<ll> a(n);
		for (ll i = 0; i < n; ++i)cin >> a[i];
		ll ans = 0;
		for(ll i = l; i <= r; ++i) {
			ans += (check(i, a) == 0);
		}
		cout << ans << "\n";
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3444
final_rank: 17

code_snippet: #include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }
template<typename T=ll,size_t N>
array<T,N> arrin(){array<T,N> x;REP(i,N){ x[i]=in<T>(); }return x;}

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

template<typename T>
bool chmax(T& a,T b){ if(a<b){ a=b;return true; }return false; }
template<typename T>
bool chmin(T& a,T b){ if(a>b){ a=b;return true; }return false; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	while(true){
		auto N=in(),L=in(),R=in();
		if(!N) break;

		auto A=vecin(N);
		ll S=0;
		FOR(i,L,R+1){
			bool exist=false;
			REP(j,N){
				if(!(i%A[j])){
					exist = true;
					if(j%2){
						break;
					}
					else{
						S++;
						break;
					}
				}
			}
			if(exist) continue;
			if(!(N%2)) S++;
		}
		out(S);
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3360
final_rank: 9

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rrep(i,l,r) for(int i=l;i<=r;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define unq(x) sort(all(x));x.erase(unique(all(x)),x.end())
//#define mod 1000000007
#define mod 998244353
//ll mod;
#define ad(a,b) a=(a+b)%mod;
#define mul(a,b) a=a*b%mod;
void readv(vector<ll> &a,ll n){
	rep(i,n){
		ll x;
		cin>>x;
		a.push_back(x);
	}
}
void outv(vector<ll> &a,ll n){
	rep(i,n){
		if(i>0)cout<<" ";
		cout<<a[i];
	}
	cout<<"\n";
}
ll po(ll x,ll y){
	ll res=1;
	for(;y;y>>=1){
		if(y&1)res=res*x%mod;
		x=x*x%mod;
	}
	return res;
}
ll gcd(ll a,ll b){
	return (b?gcd(b,a%b):a);
}
#define FACMAX 200010
ll fac[FACMAX],inv[FACMAX],ivf[FACMAX];
void initfac(){
	fac[0]=ivf[0]=inv[1]=1;
	for(ll i=1;i<FACMAX;i++)fac[i]=fac[i-1]*i%mod;
	for(ll i=1;i<FACMAX;i++){
		if(i>1)inv[i]=(mod-mod/i*inv[mod%i]%mod)%mod;
		ivf[i]=po(fac[i],mod-2);
	}
}
ll P(ll n,ll k){
	if(n<0||n<k)return 0;
	return fac[n]*ivf[n-k]%mod;
}
ll C(ll n,ll k){
	if(k<0||n<k)return 0;
	return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}
ll H(ll n,ll k){
	return C(n+k-1,k);
}

ll n,l,r,a[55];
bool is_uruu(ll x){
	for(int i=1;i<=n;i++){
		if(x%a[i]==0){
			if(i%2==0)return 0;
			if(i%2==1)return 1;
		}
	}
	if(n%2==0)return 1;
	if(n%2==1)return 0;
	assert(false);
	return 0;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	while(1){
		cin>>n>>l>>r;
		if(n==0&&l==0&&r==0)break;
		for(int i=1;i<=n;i++)cin>>a[i];
		ll ans=0;
		for(int x=l;x<=r;x++){
			ans+=is_uruu(x);
		}
		cout<<ans<<endl;
	}
}
accuracy: 1
time_ms: 10
memory_kb: 3376
final_rank: 14

code_snippet: #include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<vp> graph;
typedef vector<char> vc;
typedef vector<vc> vvc;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
// const ll MOD = 1000000007;
const ll MOD = 998244353;
const ll INF = 1000000000000000000;
void yn(bool ok) { cout << (ok ? "yes\n" : "no\n"); }
void Yn(bool ok) { cout << (ok ? "Yes\n" : "No\n"); }
void YN(bool ok) { cout << (ok ? "YES\n" : "NO\n"); }
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll dx[8] = {-1, 0, 1, 0, 1, -1, 1, -1}, dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
void solve() {
    ll n, l, r;
    cin >> n >> l >> r;
    if (!n) exit(0);
    vl a(n);
    for (auto& x : a) cin >> x;
    ll res = 0;
    for (int i = l; i <= r; i++) {
        bool f = 0;
        for (int j = 0; j < n; j++) {
            if (i % a[j] == 0) {
                if (j % 2 == 0) {
                    res++;
                }
                f = 1;
                break;
            }
        }
        if (!f && n % 2 == 0) res++;
    }
    cout << res << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll t = 1;
    // cin >> t;
    for (int i = 1;; i++) solve();
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3360
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;

vector<ll> input(int n) {
    vector<ll> res(n);
    for (auto& x : res) cin >> x;
    return res;
}

ll solve(ll n, ll l, ll r) {
    auto a = input(n);
    ll ans = 0;
    for (int i = l ; i <= r ; i++) {
        bool ch = false;
        for (int j = 0 ; j < n ; j++) if (i % a[j] == 0) {
            ch = true;
            ans += (j + 1) % 2;
            break;
        }
        if (!ch) ans += 1 - (n % 2);
    }

    return ans;
}

int main() {
    while(1) {
        ll n, l, r; cin >> n >> l >> r;
        if (!n) break;
        cout << solve(n, l, r) << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3212
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve(ll n, ll l, ll r) {
    vector<ll> a(n); for (auto& x : a) cin >> x;
    ll ans = 0;
    for (int i = l ; i <= r ; i++) {
        bool ok = false;
        for (int j = 0 ; j < n ; j++) if (!(i % a[j])) {
            ans += (j + 1) % 2;
            ok = true;
            break;
        }
        if (!ok) ans += 1 - (n%2);
    }

    return ans;
}

int main() {
    while(1) {
        ll n, l, r; cin >> n >> l >> r;
        if (!n) break;
        cout << solve(n, l, r) << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3212
final_rank: 2