zoukankan      html  css  js  c++  java
  • 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
    ";continue;}
            cout<<t<<endl;
        }
        return 0;
    }
    View Code
  • 相关阅读:
    apollo使用场景2
    我问问
    洛谷 P3979 遥远的国度
    小技巧—对拍和输出文件的比较
    洛谷 P6850 NOI
    小技巧—双向边快速枚举
    ZJOI 2008 骑士
    小技巧—指数形式的枚举
    小技巧—滚动数组
    刷题心得—背包问题的枚举方式
  • 原文地址:https://www.cnblogs.com/dzzy/p/4888385.html
Copyright © 2011-2022 走看看