1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; typedef long long LL; #define CLR(x,y) memset((x),(y),sizeof((x))) #define FOR(x,y,z) for(int (x)=(y);(x)<(z);(x)++) #define FORD(x,y,z) for(int (x)=(y);(x)>=(z);(x)--) #define FOR2(x,y,z) for((x)=(y);(x)<(z);(x)++) #define FORD2(x,y,z) for((x)=(y);(x)>=(z);(x)--) const int maxn = 18 + 2; int main(){ int n,a[maxn],cntcase = 0; while (~ scanf ( "%d" ,&n)){ FOR(i,0,n) scanf ( "%d" ,&a[i]); LL res = 0; FOR(i,0,n){ FOR(j,i,n){ LL tmp = 1; FOR(k,i,j+1) tmp *= a[k]; if (res < tmp) res = tmp; } } printf ( "Case #%d: The maximum product is %lld.\n\n" ,++cntcase,res); } return 0; } |
[2016-02-19][UVA][11059][Maximum Product]
原文:http://www.cnblogs.com/qhy285571052/p/5199679.html