博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
编程题_超长正整数相加
阅读量:3944 次
发布时间:2019-05-24

本文共 497 字,大约阅读时间需要 1 分钟。

题目链接:

解题思路一:使用BigInteger类

解题思路二:字符串拆分处理

//思路一代码import java.util.*;import java.math.BigInteger;public class Main1{
public static void main(String[] args){
Scanner input=new Scanner(System.in); while(input.hasNext()){
String s1=input.next(); String s2=input.next(); BigInteger num1=new BigInteger(s1);//采用BigInteger可以直接进行大整数进行计算 BigInteger num2=new BigInteger(s2); System.out.println(num1.add(num2)); } }}

转载地址:http://vejwi.baihongyu.com/

你可能感兴趣的文章
syslog 和 rsyslog
查看>>
Linux下,write/read,recv/send, recvfrom/sendto的区别
查看>>
ubuntu下 rc.local的脚本不运行
查看>>
Linux下简单Makefile文件的编写
查看>>
linux下配置JDK JAVA环境
查看>>
解决Ubuntu 14.04 grub选择启动项10秒等待时间
查看>>
Python函数操作集锦之字符串测试、判断函数
查看>>
Python字符串操作集锦之字符串映射表
查看>>
Python字符串操作集锦之字符串编码解码函数
查看>>
Python字符串类型转换函数
查看>>
Python有用的命令
查看>>
Python条件语句
查看>>
Python eval()函数
查看>>
Linux rz和sz命令详解
查看>>
Python 集合set
查看>>
Codeforces Round #400 (Div. 1 + Div. 2, combined)D - The Door Problem(2-sat)
查看>>
IDEA中Struts2文件上传时404错误The origin server did not find a current representation for the target resour
查看>>
Perl/Tk 变量追踪及类线程实现
查看>>
1.嵌入式开发环境搭建--虚拟机安装(unbutu)系统
查看>>
2.嵌入式开发环境搭建--(unbutu)系统
查看>>