传统弱校HFUT的蒟蒻,真相只有一个

BestCoder Round #60 1001

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}-1263​​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

 

posted @ 2015-10-17 22:00  未名亚柳  阅读(145)  评论(0编辑  收藏  举报