1 条题解
-
0
直接对所有区间逐个判断即可,注意溢出问题。
#include <bits/stdc++.h> using namespace std; const int N = 100 + 12, V = 1e4 + 12; int a[N], b[N][N]; int main() { freopen("multiply.in", "r", stdin); freopen("multiply.out", "w", stdout); int n, x; cin >> n >> x; for (int i = 1; i <= n; i++) { cin >> a[i]; b[i][i] = a[i]; } for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) b[i][j] = min(b[i][j - 1] * a[j], V); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (b[i][j] == x) { cout << i << ' ' << j << endl; return 0; } cout << -1 << endl; return 0; }
- 1
信息
- ID
- 253
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 1
- 标签
- 递交数
- 12
- 已通过
- 2
- 上传者