Integer Inquiry 大数加法
1 import java.util.*;
2 import java.math.*;
3 import java.io.*;
4 import java.text.*;
5
6 public class Main
7 {
8 public static void main(String[] args)
9 {
10 // 对于大量输入,下面方式可能会快一些。
11 Scanner cin=new Scanner(new BufferedInputStream(System.in));
12 BigInteger a,b=new BigInteger("0");
13 int T;
14 T=cin.nextInt();
15 for(int i=0;i<T;i++)
16 {
17 while(true)
18 {
19 a=cin.nextBigInteger();
20 //if(!(a.toString()=="0"))
21 //if("0".equals(a.toString())==false)
22 if(a.toString()!="0")
23 {
24 b=b.add(a);
25 }
26 else
27 {
28 if(i>0)
29 System.out.println();
30 System.out.println(b);
31
32 b=new BigInteger("0");
33 break;
34 }
35 }
36 }
37 cin.close();
38 }
39 }
Integer Inquiry 大数加法的更多相关文章
- hdu acm-1047 Integer Inquiry(大数相加)
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- POJ 1503 Integer Inquiry(大数相加,java)
题目 我要开始练习一些java的简单编程了^v^ import java.io.*; import java.util.*; import java.math.*; public class Main ...
- POJ 1503 Integer Inquiry(大数相加)
一.Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his exp ...
- HDU 1047 Integer Inquiry 大数相加 string解法
本题就是大数相加,题目都不用看了. 只是注意的就是HDU的肯爹输出,好几次presentation error了. 还有个特殊情况,就是会有空数据的输入case. #include <stdio ...
- POJ 1503 Integer Inquiry 大数 难度:0
题目链接:http://poj.org/problem?id=1503 import java.io.*; import java.math.BigInteger; import java.util. ...
- Integer Inquiry(大数相加)
Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his explo ...
- Integer Inquiry【大数的加法举例】
Integer Inquiry Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 27730 Accepted: 10764 ...
- UVa 424 Integer Inquiry 【大数相加】
解题思路:因为给定的数据是多组,所以我们只需要多次做加法就可以了,将上一次的和又作为下一次加法运算的一个加数. 反思:还是题意理解不够清楚,最开始以为只是算三个大数相加,后来才发现是多个,然后注意到当 ...
- (大数 string) Integer Inquiry hdu1047
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
随机推荐
- SVN库迁移到GitHub
创建新目录,cmd进入到新目录,执行如下命令: git svn init svn://10.10.10.10/net/QA_Dept git svn fetch git remote add orig ...
- 6.6 rsync:文件同步工具
rsync 是一款开源的.快速的.多功能的.可实现全量及增量的本地或远程数据镜像同步备份的优秀工具.rsync适用于Unix/Linux/Windows等多种操作系统平台. rsync命令有三种常 ...
- redis 处理缓存击穿以及缓存雪崩
缓存击穿 1. 缓存击穿简述 某一个热点数据在缓存中失效,请求穿过redis到达DB,造成DB压力过大 2. 怎么解决缓存击穿 1. 使用redis 作为分布式互斥锁(mutex lock) 实现步骤 ...
- logstash收集时filebeat区分日志
logstash收集时filebeat区分日志 1.场景 filebeat在服务器中同时收集nginx和web项目日志,需要对两个日志在logstash中分别处理 2.版本区别 ==6.x之前 ...
- Java中Map<Key, Value>存储结构根据值排序(sort by values)
需求:Map<key, value>中可以根据key, value 进行排序,由于 key 都是唯一的,可以很方便的进行比较操作,但是每个key 对应的value不是唯一的,有可能出现多个 ...
- maven项目多环境打包问题
1.xxx-api是基于springboot的模块 2.配置文件 application.properties spring.profiles.active=@activeEnv@ applicati ...
- TVM代码生成codegen
TVM代码生成codegen 硬件后端提供程序(例如Intel,NVIDIA,ARM等),提供诸如cuBLAS或cuDNN之类的内核库以及许多常用的深度学习内核,或者提供框架例,如带有图形引擎的DNN ...
- MIT Graph实践概述
MIT Graph实践概述 Features功能 • iCloud Support • Multi Local & Cloud Graphs • Thread Safe • S ...
- 单核性能强悍,Core i3 这次又要“默秒全”?
单核性能强悍,Core i3 这次又要"默秒全"? 在 Intel 历代酷睿处理器中,定位主流级的 Core i3 一直以超高性价比.低功耗.低发热的特点受到广大用户的青睐,在市场 ...
- 孟老板 BaseAdapter封装(五) ListAdapter
BaseAdapter封装(一) 简单封装 BaseAdapter封装(二) Header,footer BaseAdapter封装(三) 空数据占位图 BaseAdapter封装(四) PageHe ...