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;这 ...
随机推荐
- DIV+CSS 网页布局之:三列布局
1.宽度自适应三列布局 三列布局的原理和两列布局的原理是一样的,只不过多了一列,只需给宽度自适应两列布局中间再加一列,然后重新计算三列的宽度,就实现了宽度自适应的三列布局. 同样的道理,更多列的布局, ...
- 已经安装php后,再增加扩展模块(不重新编辑php)
下面以安装curl为例,介绍具体安装步骤. 1.安装crul wget http://curl.haxx.se/download/curl-7.19.6.tar.gz tar -zxvf curl-7 ...
- 【javascript 变量和作用域】
今天学习了javascript 的变量和作用域的基本知识,对于以前在开发中遇到的一些不懂的小问题也有了系统的认识,收获还是比较多的. [基本类型和引用类型] ECMAScript 变量可能包含两种不同 ...
- torch7在mac上的安装
在安装torch7的时候,一开始一直参考的是官方的文档: http://torch.ch/docs/getting-started.html#_ 但是无论怎么装都无法成功,主要是卡在了source那一 ...
- WPF界面特殊字符处理
界面XAML不支持< .>.&."等字符. 使用字符实体编码进行替代,以下是pro WPF 4.5的摘要表 Special Character ...
- hdu 1800 Flying to the Mars
Flying to the Mars 题意:找出题给的最少的递增序列(严格递增)的个数,其中序列中每个数字不多于30位:序列长度不长于3000: input: 4 (n) 10 20 30 04 ou ...
- 《C和指针》章节后编程练习解答参考——第10章
10.1 #include <stdio.h> typedef struct { unsigned ]; unsigned ]; unsigned ]; }TelphoneNumber; ...
- 【转】ant命令总结
http://feiyeguohai.iteye.com/blog/1295922 ant命令总结 1 Ant是什么? Apache Ant 是一个基于 Java的生成工具. 生成工具在软件开发中用 ...
- 贴板子系列_1-km算法,匈牙利算法
KM算法 #include <bits/stdc++.h> #define N 1500 #define inf 999999999 using namespace std; ,ny=,k ...
- 集合工具类 - CollectionUtil.java
集合工具类,提供数组转LIST.数组转SET.合并集合.计算笛卡儿积等方法. 源码如下:(点击下载 - CollectionUtil.java.ArrayUtil.java.commons-lang ...