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
  • 相关阅读:
    Win8常用快捷键
    清除远程桌面连接记录
    通过注册表改变“我的文档”等的默认位置,防止系统重装造成数据丢失
    HTML 转义字符对照表
    r语言 函数
    sparkr——报错
    R语言--saprkR基本使用
    r绘图基本
    R绘制中国地图,并展示流行病学数据
    r画饼图
  • 原文地址:https://www.cnblogs.com/dzzy/p/4888385.html
Copyright © 2011-2022 走看看