#include<bits/stdc++.h> usingnamespacestd; using ll = longlong;
inlineintrd(){ int x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) f |= (c == '-'); for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); return f ? -x : x; }
#define N 57 #define M 5007 #define B 2500
ll f[N][M];
intmain(){ int n = rd(), A = rd(); f[0][B] = 1; for (int i = 1; i <= n; ++i) { int w = rd() - A; for (int v = max(-B, -B + w); v <= min(B, B + w); ++v) f[i][v + B] = f[i - 1][v + B] + f[i - 1][v - w + B]; } printf("%lld\n", f[n][B] - 1); return0; }
#include<bits/stdc++.h> usingnamespacestd; using ll = longlong;
inline ll calc(ll n, ll b){ ll ans = 0; for (; n; ans += n % b, n /= b); return ans; }
intmain(){ ll n, s; cin >> n >> s; if (n < s) {puts("-1"); return0;} if (n == s) {printf("%lld\n", n + 1); return0;} ll lim = sqrt(n); for (ll i = 2; i <= lim; ++i) if (calc(n, i) == s) {printf("%lld\n", i); return0;} n -= s; ll ans = 1e18; for (ll i = sqrt(n); i >= 1; --i) if (n % i == 0) { if (i >= lim && s - n / i < i + 1 && s >= n / i) ans = min(ans, i + 1); if (n / i >= lim && s - i < n / i + 1 && s >= i) ans = min(ans, n / i + 1); } printf("%lld\n", ans == 1e18 ? -1 : ans); return0; }
#include<bits/stdc++.h> usingnamespacestd; using ll = longlong;
inlineintrd(){ int x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) f |= (c == '-'); for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); return f ? -x : x; }
#define N 100007
int r[N][18], x[N];
intmain(){ int n = rd(); int t = log2(n) + 1; for (int i = 1; i <= n; ++i) x[i] = rd(); int l = rd(), q = rd(); for (int i = 1, rpos = 1; i <= n; ++i) { while (rpos < n && x[rpos + 1] - x[i] <= l) ++rpos; r[i][0] = rpos; } for (int i = 1; i <= t; ++i) for (int l = 1; l <= n; ++l) r[l][i] = r[r[l][i - 1]][i - 1];
for (; q; --q) { int a = rd(), b = rd(); if (a > b) swap(a, b); int ans = 0; for (int i = t; ~i; --i) if (r[a][i] < b) { ans += (1 << i); a = r[a][i]; } printf("%d\n", ans + 1); } return0; }