例题7-2 最大乘积(Maximum Product, UVa 11059)
2017-09-26 22:15
411 查看
通过枚举左右区间来枚举连续子序列。。这数据,随便瞎搞。。。还是迷之wa了几发。。QAQ。。
#include <iostream> #include <string> #include <vector> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <algorithm> #include <sstream> #include <utility> #include <cstring> #include <cstdio> #include <cstdlib> #include <ctime> #include <cmath> #include <cctype> #define CLEAR(a, b) memset(a, b, sizeof(a)) #define IN() freopen("in.txt", "r", stdin) #define OUT() freopen("out.txt", "w", stdout) #define LL long long #define maxn 105 #define maxm 10005 #define mod 1000000007 #define INF 1000000007 #define eps 1e-5 #define PI 3.1415926535898 #define N 26 using namespace std; //-------------------------CHC------------------------------// LL a[20]; int main() { int n, kase = 1; while (~scanf("%d", &n)) { for (int i = 0; i < n; ++i) { scanf("%lld", &a[i]); } LL ans = 0; for (int l = 0; l < n; ++l) for (int r = l + 1; r <= n; ++r) { LL prod = 1; for (int i = l; i < r; ++i) prod *= a[i]; ans = max(ans, prod); } if (kase > 1) putchar('\n'); printf("Case #%d: The maximum product is %lld.\n", kase++, ans); } return 0; }
相关文章推荐
- 最大乘积(Maximum Product,UVa 11059)
- 暴力求解——最大乘积 Maximum Product,UVa 11059
- 最大乘积(Maximum Product,UVa 11059)
- 最大乘积(Maximum Product,UVA 11059)
- UVA 11059 Maximum Product最大乘积(暴力法)
- 最大乘积(Maximum Product,UVA 11059)
- 最大乘积(Maximum Product,UVA 11059)
- 最大乘积(Maximum Product,UVa 11059)
- 例题7-2 最大乘积 UVa 11059
- [Day Zero] 7.1-2 最大乘法(Maximum Product,UVa 11059)
- DP36 如何切出最大长度乘积 Maximum Product Cutting @geeksforgeeks
- UVa 11059 最大乘积
- UVa 11059 最大乘积(枚举)
- 【LeetCode-面试算法经典-Java实现】【152-Maximum Product Subarray(子数组的最大乘积)】
- Maximum Product Subarray 最大连续乘积子集
- 【LeetCode】Maximum Product Subarray 求连续子数组使其乘积最大
- Leetcode 152 Maximum Product Subarray 子数组最大乘积
- 最大乘积 Uva 11059
- [LeetCode] Maximum Product Subarray 求最大子数组乘积
- 最大乘积 Uva 11059