BigInteger Uva
import java.io.*;
import java.math.BigInteger;
import java.util.*; public class Main {
public static void main(String[] args)
{
BigInteger ans,Zero; Zero = BigInteger.ZERO;
ans = BigInteger.ZERO;
Scanner cin = new Scanner(System.in);
while(cin.hasNextBigInteger())
{
BigInteger temp = cin.nextBigInteger();
if(temp.equals(Zero)) break;
ans = ans.add(temp);
}
System.out.println(ans);
}
}
import java.io.*;
import java.math.BigInteger;
import java.util.*; public class Main {
public static void main(String[] args)
{
BigInteger a,b; Scanner cin = new Scanner(System.in); while(cin.hasNextBigInteger())
{
a = cin.nextBigInteger();
b = cin.nextBigInteger();
System.out.println(a.multiply(b));
} }
}
import java.math.BigInteger;
import java.util.*; public class Main {
public static void main(String[] args)
{
BigInteger a,b,c;
String p,q;
Scanner cin = new Scanner(System.in); while(cin.hasNext())
{
p = cin.next();
String s = cin.next();
char ch = s.charAt(0);
q = cin.next(); System.out.println(p+" "+s+" "+q);
a = new BigInteger(p);
b = new BigInteger(q); if(ch == '+')
c = a.add(b);
else
c = a.multiply(b); if(a.bitLength() > 31)
{
System.out.println("first number too big");
}
if(b.bitLength() > 31)
{
System.out.println("second number too big");
}
if(c.bitLength() > 31)
{
System.out.println("result too big");
}
}
}
}
BigInteger Uva的更多相关文章
- uva 11357 Matches
// uva 11357 Matches // // 题目大意: // // 给你n个火柴,用这n个火柴能表示的非负数有多少个,不能含有前导零 // // 解题思路: // // f[i] 表示正好用 ...
- UVa 10007 - Count the Trees(卡特兰数+阶乘+大数)
题目链接:UVa 10007 题意:统计n个节点的二叉树的个数 1个节点形成的二叉树的形状个数为:1 2个节点形成的二叉树的形状个数为:2 3个节点形成的二叉树的形状个数为:5 4个节点形成的二叉树的 ...
- UVA 10254 十八 The Priest Mathematician
The Priest Mathematician Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu ...
- UVa 11375 - Matches
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- BigInteger
首先上模板(不断更新中...)(根据刘汝佳AOAPCII修改) #include <iostream> #include <sstream> #include <cstd ...
- uva 10007 Count the Trees
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- UVa 10213 - How Many Pieces of Land ?(欧拉公式)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVA 10328 - Coin Toss dp+大数
题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_proble ...
- ACM中java中BigInteger和Decimal用到的主要函数
java中大数以及高精度常用函数 使用java大数类解决问题时我们需要注意两个方面:1.不能有包名,也就是说我们要把主类放到默认的包里,如果你的代码里出现形如package cn.gov.test;这 ...
随机推荐
- AOP学习过程中遇到的问题汇总
jdk版本问题: 在spring较低的版本中,仅支持jdk1.5到1.7版本,由于我本机安装的是jdk1.8,所以在调试的时候就会提示jdk版本要高于1.5.于是换成spring4.0,在co ...
- varnish 4.0编译安装小记
varnish 4.0 编译问题 centos-6.5 x86环境 装varnish遇到几个错误要先安装python-docutils然后提示error1,于是安装:libedit-devel然后提示 ...
- jquery 之事件 多库共存(noConflict)
/*jquery 之 简单事件jquery 与其它库共存,提供了 .noConflict() 方法,用法如下<script src="jquery 库"><scr ...
- TDirectory.IsEmpty判断指定目录是否为空
使用函数: System.IOUtils.TDirectory.IsEmpty class function IsEmpty(const Path: string): Boolean; static; ...
- Python的简介以及安装和第一个程序以及用法
Python的简介: 1.Python是一种解释型.面向对象.动态数据类型的高级程序设计语言.自从20世纪90年代初Python语言诞生至今,它逐渐被广泛应用于处理系统管理任务和Web编程.Pytho ...
- 懒加载 jquery代码
懒加载代码.据说这是jquery代码. 说白了就是在 开始的时候调用,这个和C#代码错误处理机制是一样的. function check() { var obj = document ...
- Object.defineProperty
属性类型ECMA-262第5版在定义只有内部才用的特性(attribute)时,描述了属性(property)的各种特征.ECMA-262定义这些特性是为了实现JavaScript引擎用的,因此在Ja ...
- Investigation of Different Nets and Layers
Investigation of Different Nets and Layers Overview of AlexNet (MIT Places | Flickr Finetuned | Oxfo ...
- 设计模式之策略模式Strategy
/** * 策略设计模式 * 策略模式:定义一系列的算法族,使他们之间可以相互转换,动态的改变其行为. * 问题:设计一个鸭子模拟游戏. * 现在有一群鸭子: * ①这些鸭可以有飞的行为(分为快和慢) ...
- [转贴]C语言复习笔记-17种小算法-解决实际问题
判断日期为一年中的第几天(考虑闰年) /* * 计算该日在本年中是第几天,注意闰年问题 * 以3月5日为例,应该先把前两个月的加起来,然后再加上5天即本年的第几天 * 特殊情况,闰年且输入月份大于3时 ...