Integer Inquiry HDU - 1047 高精度
``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.)
InputThe 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 a single zero on 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 is an integer N, then a blank line followed by N input blocks. Each input block is 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
1 123456789012345678901234567890 123456789012345678901234567890 123456789012345678901234567890 0
Sample Output
370370367037037036703703703670
import java.math.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n; BigInteger zero=BigInteger.valueOf(0); n=sc.nextInt(); while(n-->0) { BigInteger s=BigInteger.valueOf(0); BigInteger a[]=new BigInteger[1010]; for(int i=0;;i++) { a[i]=cin.nextBigInteger(); if(a[i].equals(zero)) break; else s=s.add(a[i]); } System.out.println(s); if(n!=0) System.out.println(""); } } }
原文地址:https://www.cnblogs.com/xxxsans/p/12795392.html
- 【大牛经验】Web服务器的工作原理
- 使用shell定制addm脚本(r3笔记第88天)
- 【专业技术第十三讲】指针和内存泄露
- 【Java案例】余弦函数
- MySQL数据类型(r3笔记第87天)
- NLP真实项目:利用这个模型能够通过商品评论去预测一个商品的销量
- python + selenium + PhantomJS 获取腾讯应用宝APP评论
- 简单实用的sql小技巧(第二篇)(r3笔记第86天)
- Java代码效率优化【面试+提高】
- 利用逻辑回归模型判断用户提问意图
- 关于reset sequence(r3笔记第85天)
- 【编程基础第十二讲】web开发编程基础--回调函数
- typeof的一些兼容性问题
- 类型转换的判定方式
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 带你认识Pytest(三)
- Additive Powers-of-Two (APoT) Quantization:硬件友好的非均匀量化方法
- Flutter基础widgets教程-SnackBar篇
- Redash 二开 - 后端环境搭建
- Flutter基础widgets教程-Stepper篇
- Flutter基础widgets教程-Switch篇
- 13.深入k8s:Pod 水平自动扩缩HPA及其源码分析
- python 协程新版
- 14.深入k8s:kube-proxy ipvs及其源码分析
- netty
- Flutter基础widgets教程-TabBar篇
- 厉害了!华为将发布国产编程语言,打破国外垄断!
- Flutter基础widgets教程-TabBarView篇
- 求求你不要在用!=null判空了
- Geant4--root和csv文件存储