UVA.10305 Maximum Product (暴力)

题意分析

直接枚举起点和重点,然后算出来存到数组里面,sort然后取最大值即可。

代码总览

  1. #include <iostream>
  2. #include <iostream>
  3. #include <cstdio>
  4. #include <algorithm>
  5. #include <cstring>
  6. #include <sstream>
  7. #include <set>
  8. #include <map>
  9. #include <queue>
  10. #include <stack>
  11. #include <cmath>
  12. #define nmax 10000
  13. #define MEM(x) memset(x,0,sizeof(x))
  14. int number[nmax];
  15. long long a[nmax];
  16. using namespace std;
  17. bool cmp(long long x, long long y)
  18. {
  19. if(x>y) return true;
  20. else return false;
  21. }
  22. int main()
  23. {
  24. //freopen("in.txt","r",stdin);
  25. //freopen("out.txt","w",stdout);
  26. int n;int kase = 1;
  27. while(scanf("%d",&n) != EOF){
  28. MEM(a);MEM(number);
  29. for(int i = 1; i<=n; ++i) scanf("%d",&number[i]);
  30. int cnt = 0;
  31. for(int i = 1;i<=n;++i){
  32. for(int j = i; j<=n;++j){
  33. if(j == i){
  34. a[cnt++] = number[i];
  35. }else{
  36. a[cnt] = a[cnt-1] * number[j];
  37. cnt++;
  38. }
  39. }
  40. }
  41. sort(a,a+cnt,cmp);
  42. printf("Case #%d: The maximum product is %lld.\n\n",kase++,a[0]>0?a[0]:0);
  43. }
  44. return 0;
  45. }

UVA.10305 Maximum Product (暴力)的更多相关文章

  1. UVa 11059 - Maximum Product 最大乘积【暴力】

    题目链接:https://vjudge.net/contest/210334#problem/B 题目大意:Given a sequence of integers S = {S1, S2, . . ...

  2. UVA 11059 Maximum Product【三层暴力枚举起终点】

    [题意]:乘积最大的子序列.n∈[1,10],s∈[-10,10] [代码]: #include<bits/stdc++.h> using namespace std; int a[105 ...

  3. uva 11059 maximum product(水题)——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAB1QAAAMcCAIAAABo0QCJAAAgAElEQVR4nOydW7msuhKF2wIasIAHJK

  4. Uva 11059 Maximum Product

    注意long long  long long  longlong !!!!!!   还有 printf的时候 明明longlong型的答案 用了%d  WA了也看不出,这个细节要注意!!! #incl ...

  5. Codeforces Round #670 (Div. 2) B. Maximum Product (暴力)

    题意:有一长度为\(n\)的序列,求其中任意五个元素乘积的最大值. 题解:先排序,然后乘积能是正数就搞正数,模拟一下就好了. 代码: int t; ll n; ll a[N]; int main() ...

  6. 暴力求解——最大乘积 Maximum Product,UVa 11059

    最大乘积 Maximum Product 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=84562#problem/B 解题思路 ...

  7. 最大乘积(Maximum Product,UVA 11059)

    Problem D - Maximum Product Time Limit: 1 second Given a sequence of integers S = {S1, S2, ..., Sn}, ...

  8. 【例题 7-2 UVA - 11059】Maximum Product

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] C语言for循环练习题 [代码] /* 1.Shoud it use long long ? 2.Have you ever tes ...

  9. Maximum Product UVA - 11059

    Given a sequence of integers S = {S1, S2, . . . , Sn}, you should determine what is the value of the ...

随机推荐

  1. 2019年猪年海报PSD模板-第八部分

    11套精美猪年海报,免费猪年海报,下载地址:百度网盘,https://pan.baidu.com/s/1Y3wc_r7O-Dp0mLCihJ9mtQ            

  2. ElasticSearch搜索引擎安装配置拼音插件pinyin

    近几篇ElasticSearch系列: 1.阿里云服务器Linux系统安装配置ElasticSearch搜索引擎 2.Linux系统中ElasticSearch搜索引擎安装配置Head插件 3.Ela ...

  3. python3 小实践(一)——selenium获取的cookie传递

    from selenium import webdriver from time import sleep import requests import pickle #获取登录后的cookies c ...

  4. python操作字符串内容并重新输出

    今天在做一个函数的作业,题目如下: 编写一个函数实现大写转小写,小写变大写,并且转换为镜像字符串,并且将字符串变为镜像字符串. 例如:’A’变为’Z’,’b’变为’y 示范字符串: ”sdSdsfdA ...

  5. 第一模块·开发基础-第1章 Python基础语法

    Python开发工具课前预习 01 Python全栈开发课程介绍1 02 Python全栈开发课程介绍2 03 Python全栈开发课程介绍3 04 编程语言介绍(一) 05 编程语言介绍(二)机器语 ...

  6. 系统滴答定时器(SysTick)中断配置

    系统滴答定时器(SysTick)中断配置 在STM32标准库中是通过SysTick_Config()函数配置时钟中断的,然后SysTick_Handler()函数自动定时触发其中的函数. if(Sys ...

  7. hive创建外部表

    Create [EXTERNAL] TABLE [IF NOT EXISTS] table_name [(col_name data_type [COMMENT col_comment], ...)] ...

  8. Daily Scrum8

    今天我们小组开会内容分为以下部分: part 1: 说明了search.match.upload.download功能实现流程: part 2:针对用户积分模块的任务分配: ◆Part 1 searc ...

  9. 20145214《Java程序设计》课程总结

    20145214<Java程序设计>课程总结 每周读书笔记链接汇总 第一周读书笔记 第二周读书笔记 第三周读书笔记 第四周读书笔记 第五周读书笔记 第六周读书笔记 第七周读书笔记 第八周读 ...

  10. LintCode-66.二叉树的前序遍历

    二叉树的前序遍历 给出一棵二叉树,返回其节点值的前序遍历. 样例 给出一棵二叉树 {1,#,2,3}, 返回 [1,2,3]. 挑战 你能使用非递归实现么? 标签 递归 二叉树 二叉树遍历 非递归 c ...