http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2000
中譯
http://luckycat.kshs.kh.edu.tw/homework/q11059.htm
#include "stdio.h" int main() { int N,S[20],num = 1; while( scanf(" %d",&N) != EOF && N) { int i,j,k; long long int P; for(i = 0;i < N;i++) { scanf(" %d",&S[i]); if(i == 0) P = S[i]; else { for(j = 0;j <= i;j++) { long long int tmp = 1; for(k = j;k <=i;k++) tmp *= S[k]; if( P < tmp ) P = tmp; } } } if( P < 0 ) P = 0; printf("Case #%d: The maximum product is %lld.\n\n",num,P); num++; } return 0; }
沒有留言:
張貼留言