5504 GT and sequence
来源:互联网 发布:软件项目实施报告 编辑:程序博客网 时间:2024/05/17 06:39
分析:题意就是给你n个数,让你至少选一个数,使得你选的这些数的乘积最大。如果只有1个数,就直接输出了,如果有正数或负数的个数大于2,答案肯定大于0,否则答案为0.
# include <stdio.h># include <algorithm> using namespace std; int main() { int i,n,T,t,f; __int64 x,ans,a[100]; scanf("%d",&T); while(T--) { scanf("%d",&n); if(n==1) { scanf("%I64d",&x); printf("%I64d\n",x); continue; } t=f=0; ans=1; for(i=0;i<n;i++) { scanf("%I64d",&x); if(x>0) ans=ans*x,f=1; else if(x<0) a[t++]=x; } if(f==0&&t<=1) { printf("0\n"); continue; } sort(a,a+t); for(i=0;i<t-1;i+=2) ans=ans*a[i]*a[i+1]; printf("%I64d\n",ans); } return 0; }
0 0
- GT and sequence 5504GT and sequence
- 5504 GT and sequence
- HDU 5504:GT and sequence
- HDU 5504 GT and sequence
- HDOJ 5504-GT and sequence
- HDU 5504 GT and sequence
- hdu(5504)——GT and sequence
- HDU 5504 GT and sequence 模拟
- HDU 5504 GT and sequence(贪心)
- hdu 5504 GT and sequence(dp)
- HDOJ 5504 GT and sequence (乱搞)
- 杭电5504 GT and sequence
- 杭电-5504GT and sequence
- hdu5504 GT and sequence
- hdu5504 GT and sequence
- HDU_5504 GT and sequence
- GT and sequence
- hdu5504 GT and sequence
- 面向对象第一次实验参考代码
- 深入理解Activity-任务,回退栈,启动模式
- 地址/数据/控制总线原理讲解
- 在linux上搭建gtest
- 人生感悟
- 5504 GT and sequence
- 网站技术点汇总
- storm集群搭建
- Android 事件分发机制详解--真正的解析
- Merge Two Sorted Lists(C++)
- 天声人語 20151018 「老益」に至るみち
- 面向对象第二次作业参考代码
- kali linux解决LC_CTYPE,LC_ALL的设置问题
- [黑马训练营]IOS C语言分支语句