java hdu A+B for Input-Output Practice (IV)

A+B for Input-Output Practice (IV)

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 105601    Accepted Submission(s): 55782

Problem Description

Your task is to Calculate the sum of some integers.

Input

Input contains multiple test cases. Each test case contains a integer N, and then N integers follow in the same line. A test case starting with 0 terminates the input and this test case is not to be processed.

Output

For each group of input integers you should output their sum in one line, and with one line of output for each line in input.

Sample Input

4 1 2 3 4
5 1 2 3 4 5
0

Sample Output

10
15

Author

lcy

Recommend

JGShining   |   We have carefully selected several similar problems for you:  1093 1094 1095 1096 1000

怎么处理大数累加问题

import java.math.BigInteger;
import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        BigInteger a,b,d;
        String c = "0";
        d = new BigInteger(c);
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt())
        {
            b = d;
            int t = in.nextInt();
            if(t == 0)
                break;
            for(int i=1;i<=t;i++)
            {
                a = in.nextBigInteger();
                b = a.add(b);//注意使用add方法时有返回值!!!
            }
            System.out.println(b);
        }
    }
}
时间: 2024-08-24 23:00:29

java hdu A+B for Input-Output Practice (IV)的相关文章

hdu 1092 A+B for Input-Output Practice (IV)

A+B for Input-Output Practice (IV) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 90793    Accepted Submission(s): 48215 Problem Description Your task is to Calculate the sum of some integers.

黑马程序员——java基础---IO(input output)流字符流

黑马程序员——java基础---IO(input output)流字符流 ------Java培训.Android培训.iOS培训..Net培训.期待与您交流! ------- io(input output)流特点: 1,io流用来处理数据之间的传输 2,java对数据的操作是通过流的方式: 3,java用于操作流的对象都在io包中: 4,流按操作数据分为两种:字节流和字符流: 5,流按流向分为:输入流和输出流. 注意:流只能操作数据,而不能操作文件. 3.IO流的常用基类: 1)字节流的抽象

JAVA学习分享Input Output

IO(Input  Output)流 IO流用来处理设备之间的数据传输 Java对数据的操作是通过流的方式 Java用于操作流的对象都在IO包中 流按操作数据分为两种:字节流与字符流. 流按流向分为:输入流,输出流. IO流常用基类 字节流的抽象基类: InputStream ,OutputStream. 字符流的抽象基类: Reader , Writer. 注:由这四个类派生出来的子类名称都是以其父类名作为子类名的后缀. (InputStream的子类FileInputStream.) (Re

Reading and writing files in Java (Input/Output) - Tutorial

Java Input Output This tutorial explains how to read and write files via Java. Table of Contents 1. Java I/O (Input / Output) for files 1.1. Overview 1.2. Reading a file in Java 1.3. Writing a file in Java 1.4. How to identify the current directory 2

数据库服务器Input/output error (故障20170122)

描述: 数据库系统出现告警,登陆查看使用系统命令报错,提示Input/output error 模拟故障处理过程: 检查文件系统时,该文件系统必须卸载.当出现错误时fsck会提示是否修复, 可以用-y参数:不提示是否修复 fsck - check and repair a Linux file system # df -h Filesystem            Size  Used Avail Use% Mounted on /dev/mapper/vg_mysql80-lv_root 2

解决NGINX+PHP-FPM failed to ptrace(PEEKDATA) Input/output error出错问题

网站总是出现bad gateway 提示,时有,时无,查看了一下日志,居然出现一堆错误,如下 [29-Mar-2014 22:40:10] ERROR: failed to ptrace(PEEKDATA) pid 4276: Input/output error (5) [29-Mar-2014 22:53:54] ERROR: failed to ptrace(PEEKDATA) pid 4319: Input/output error (5) [29-Mar-2014 22:56:30]

解决ubuntu挂载NTFS磁盘时出现input/output error

错误内容如下: Error mounting: mount exited with exit code 13: ntfs_attr_pread_i: ntfs_pread failed: Input/output error Failed to read NTFS $Bitmap: Input/output error NTFS is either inconsistent, or there is a hardware fault, or it's a SoftRAID/FakeRAID ha

Input/output subsystem having an integrated advanced programmable interrupt controller for use in a personal computer

A computer system is described having one or more host processors, a host chipset and an input/output (I/O) subsystem. The host processors are connected to the host chipset by a host bus. The host chipset is connected to the input/output subsystem by

JAVA HDU 2048 神、上帝以及老天爷

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2048 一开始用的System.out.printf("%.2f%%\n", result)输出,PRESENTATION ERROR.  换成System.out.println(String.format("%.2f", result)+"%")就好了 1 package hdu; 2 3 import java.io.BufferedInputS