[UVA] 11059 Maximum Product
2017-03-02 21:35
375 查看
题目分析:暴力,直接枚举起点和终点,乘积最大不超过10的18次方,可以用long long 存下。
题目代码:
题目代码:
#include<iostream> #include<cstdio> #include<cstring> using namespace std ; int s[50]; int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int n; int m=0; int num=0; while(scanf("%d",&n)!=EOF){ memset(s,0,sizeof(s)); long long max = 0; for(int i = 1 ; i<= n ; i++){ scanf("%d",&s[i]); } long long ans = 1 ; for(int i = 1 ; i <= n ; i++){ for(int j = i ;j <=n ;j++){ ans=1; for(int t = i ; t <= j ;t++){ ans *= s[t]; } if(ans>max){ max = ans ; } } } printf("Case #%d: The maximum product is %lld.\n\n",++num,max); } return 0 ; }
相关文章推荐
- Uva 11059 Maximum Product
- 紫书章七 例题2 UVA 11059 Maximum Product
- UVA 11059 Maximum Product (暴力)
- UVa 11059 Maximum Product
- 紫书章七 例题2 UVA 11059 Maximum Product
- UVa 11059 - Maximum Product
- uva 11059 maximum product(水题)——yhx
- Uva - 11059 - Maximum Product
- UVa11059 Maximum Product
- Uva 11059 Maximum Product(简单枚举)
- UVA-11059 Maximum Product
- 紫书章七 例题2 UVA 11059 Maximum Product
- UVA - 11059 Maximum Product
- uva 11059 Maximum Product
- Uva - 11059 - Maximum Product
- 紫书章七 例题2 UVA 11059 Maximum Product
- UVa 11059----Maximum Product(最长上升子序列乘积)
- UVA - 11059 Maximum Product