while (!q.empty()) { int u = q.front(); q.pop(), vis[u] = false; for (auto ed : e[u]) { int v = ed.first, w = ed.second; if (dis[v] > dis[u] + w) { dis[v] = dis[u] + w; if (!vis[v]) q.push(v), vis[v] = true; } } }
returntrue; }
intmain(){ int n; longlong l, r; staticint a[13];
std::cin >> n >> l >> r;
int minA = MAXN + 1; for (int i = 1; i <= n; i++) { std::cin >> a[i]; minA = std::min(minA, a[i]); }
for (int i = 0; i < minA; i++) { for (int j = 1; j <= n; j++) { if (a[j] != minA) { add(i, (i + a[j]) % minA, a[j]); } } }
spfa(0);
longlong ans = 0; for (int i = 0; i < minA; i++) { if (r >= dis[i]) ans += (r - dis[i]) / minA + 1; if (l - 1 >= dis[i]) ans -= (l - 1 - dis[i]) / minA + 1; }