| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 41944 | Gapple | 【S】T3 | C++ | 运行超时 | 86 | 2035 MS | 16036 KB | 1563 | 2026-06-06 14:00:14 |
#include <iostream> #include <set> #include <vector> using namespace std; using i64 = long long; i64 gcd(i64 x, i64 y) { while (y != 0) { i64 t = x % y; x = y; y = t; } return x; } inline i64 lcm(i64 x, i64 y) { if (x == 0) return y; else if (y == 0) return x; else return x * y / gcd(x, y); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int T; cin >> T; while (T-- > 0) { int n; cin >> n; bool have_1 = false; vector<int> a(n); for (int& x : a) { cin >> x; if (x == 1) have_1 = true; } if (!have_1) { cout << "1\n"; continue; } set<int> vis; for (int i = 0; i < n; ++i) { int cur = 0; for (int j = i; j < n; ++j) { i64 nxt = lcm(cur, a[j]); if (nxt > 1 << 30) break; cur = nxt; vis.insert(cur); } } vis.erase(-1); int lst = 0; bool found = false; for (int x : vis) { if (x - lst > 1) { cout << lst + 1 << '\n'; found = true; break; } lst = x; } if (!found) cout << lst + 1 << '\n'; } cout << flush; return 0; }