首页 > 其他 > 详细

BestCoder Round #60 1001

时间:2015-10-17 23:42:46      阅读:306      评论:0      收藏:0      [点我收藏+]
Problem Description

You are given a sequence of NNN integers.

You should choose some numbers(at least one),and make the product of them as big as possible.

It guaranteed that the absolute value of any product of the numbers you choose in the initial sequence will not bigger than 263−12^{63}-12?63??1.

Input

In the first line there is a number TTT (test numbers).

For each test,in the first line there is a number NNN,and in the next line there are NNN numbers.

1≤T≤10001 \leq T \leq 10001T1000 1≤N≤621 \leq N \leq 621N62

You‘d better print the enter in the last line when you hack others.

You‘d better not print space in the last of each line when you hack others.

Output

For each test case,output the answer.

Sample Input
1
3
1 2 3
Sample Output
6

23333这道题大数据没过。水题判断下正负/减掉0/乘起来即可,想再试下unsign LL感觉有戏,原代码贴上
技术分享
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
using namespace std;
long long a,b,c,t;
int d,e=0,f,i,j;
int main()
{
    freopen("stdin.txt","r",stdin);
    scanf("%d",&f);
    while(f!=0)
    {
        f--;
        e=d=b=0;
        t=1;
        scanf("%d",&d);
        for(j=1;j<=d;j++)
        {
            scanf("%I64d",&b);
            if(b==0) continue;
            t*=b;
            e=1;
        }
        if(t<0) t=-t;
        if(e==0) {cout<<"0\n";continue;}
        cout<<t<<endl;
    }
    return 0;
}
View Code

 

BestCoder Round #60 1001

原文:http://www.cnblogs.com/dzzy/p/4888385.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!