UVA11059 Maximum Product

来源:互联网 发布:手机字体增大软件 编辑:程序博客网 时间:2024/05/17 04:32


暴力求解即可。

#include <stdio.h>int s[30];long long max;int main(){int n,index = 0;while(scanf("%d",&n) != EOF){int i,j;for(i = 0; i < n; i ++)scanf("%d",&s[i]);max = 0;long long mul;for(i = 0; i < n; i ++){mul = 1;for(j = i;  j < n; j ++){mul *= s[j];if(mul > max)max = mul;}}printf("Case #%d: The maximum product is %lld.\n\n",++index,max);}return 0;} 


0 0