Poj 1503 integer inquiry [Java for adding large numbers]

Source: Internet
Author: User

Integer inquiry
Time limit:1000 ms   Memory limit:10000 K
Total submissions:26642   Accepted:10325

Description

One of the first users of bit's new supercomputer was Chip Diller. He extended his activation of powers of 3 to go from 0 to 333 and he got Ed taking various sums of those numbers.
''This supercomputer is great, ''remarked chip. ''I only wish Timothy were here to 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 .)

Input

The input will consist of at most 100 lines of text, each of which contains a single verylonginteger. each verylonginteger will be 100 or fewer characters in length, and will only contain digits (no verylonginteger will be negative ).

The final input line will contain in a single zero on a line by itself.

Output

Your program shocould output the sum of the verylongintegers given in the input.

Sample Input

1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900

Sample output

 
370370367037037036703703703670

Source

East central North America 1996

1503 Accepted 3328 K 688 Ms Java 461b 02:23:25
 Import Java. util. imports; import Java. io. *; import Java. math. *; public class main {public static void main (string ARGs []) {using CIN = new using (New bufferedinputstream (system. in); biginteger A; biginteger B = new biginteger ("0"); biginteger c = new biginteger ("0"); While (CIN. hasnextbiginteger () {A = cin. nextbiginteger (); if (. compareto (c) = 0) break; B = B. add (a);} system. out. println (B) ;}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.