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
  • 相关阅读:
    设计模式
    TCP拥塞控制
    TCP 连接建立和断开,以及状态转换
    python unicode字符串
    python语法笔记(七)
    python语法笔记(六)
    python语法笔记(五)
    python语法笔记(四)
    python语法笔记(三)
    【密码学】公钥与私钥
  • 原文地址:https://www.cnblogs.com/dzzy/p/4888385.html
Copyright © 2011-2022 走看看