#include<iostream> #include<cstdio> #define maxn 310 #define ll long long usingnamespacestd;
constint p = 1000000007;
ll gcd(ll a, ll b){ return b == 0 ? a : gcd(b, a % b); }
ll mul(ll x, ll y, ll p){ return (x * y - (ll) ((longdouble) x / p * y) * p + p) % p; }
int n, m;
ll a[maxn], b[maxn];
voidwork(){ cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> a[i]; while (m--) { int l, r; cin >> l >> r; ll ans = 1; for (int i = l; i <= r; ++i) { ll s = 1; b[i] = a[i]; for (int j = l; j < i; ++j) s = mul(s, b[j], a[i]); b[i] /= gcd(b[i], s); ans = ans * (b[i] % p) % p; } cout << ans << "\n"; } }
#include<iostream> #include<cstdio> #define maxn 310 #define ll long long #define ldb long double usingnamespacestd;
constint p = 1000000007;
ll mul(ll x, ll y, ll p){ return (x * y - (ll)((ldb) x / p * y) * p + p) % p; }
ll gcd(ll a, ll b){ return b == 0 ? a : gcd(b, a % b); }
int n, m;
ll a[maxn], ans[maxn][maxn];
ll b[maxn]; voidsolve(int l, int r){ if (l == r) return ans[l][l] = a[l] % p, void(); int m = l + r >> 1; solve(l, m); solve(m + 1, r); for (int i = m; i >= l; --i) { ll s = 1; b[i] = a[i]; for (int j = m; j > i; --j) s = mul(s, b[j], b[i]); b[i] /= gcd(b[i], s); } for (int i = m + 1; i <= r; ++i) { ll s = 1; b[i] = a[i]; for (int j = m + 1; j < i; ++j) s = mul(s, b[j], b[i]); b[i] /= gcd(b[i], s); } ll s1 = 1, s2; for (int i = m; i >= l; --i) { s1 = s1 * (b[i] % p) % p; s2 = s1; for (int j = m + 1; j <= r; ++j) { ll s = gcd(b[i], b[j]); b[i] /= s; b[j] /= s; ans[i][j] = s2 = s2 * (b[j] % p) % p; } } }
voidwork(){ cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> a[i]; solve(1, n); while (m--) { int l, r; cin >> l >> r; cout << ans[l][r] << "\n"; } }