Click to open Hangzhou electric 1047
Problem Descriptionone of the first users of BIT ' s new supercomputer was Chip Diller. He extended his exploration of powers's 3 to go from 0 to 333 and he explored taking various sums of those numbers.
' This supercomputer is great, ' remarked Chip. "I only wish Timothy were" here for see these results. " (Chip moved to a new apartment, once one became available on the third floor of the Lemon Sky Apartments on third Street.)
Inputthe input would consist of in most of the lines of text, each of the which contains a single verylonginteger. Each verylonginteger'll be is fewer characters in length, and would only contain digits (no verylonginteger would be n egative).
The final input line would contain a single zero in a line by itself.
Outputyour program should output the sum of the verylongintegers given in the input.
This problem contains multiple test cases!
The first line of a multiple input was an integer N and then a blank line followed by N input blocks. Each input block was in the format indicated in the problem description. There is a blank line between input blocks.
The output format consists of N output blocks. There is a blank line between output blocks.
Sample Input
31234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900 0
Sample Output
370370367037037036703703703670 370370367037037036703703703670 0
Note: Formatting problems!!
Code implementation
Import Java.math.biginteger;import java.util.scanner;class main{public static void Main (string[] args) { Scanner sc = new Scanner (system.in); int n = sc.nextint (); while (n-->0) { BigInteger Sum=biginteger.zero; BigInteger x; while (Sc.hasnextbiginteger ()) { x=sc.nextbiginteger (); if (x.equals (biginteger.valueof (0))) { System.out.println (sum); break; } else{ Sum=sum.add (x); } } if (n!=0) { System.out.println ();}}}}
Hangzhou Electric 1047 (Integer Inquiry) Java water over