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;这 ...
随机推荐
- WinForm聊天室
前几天开始学Socket编程,跟着老师一点一点的做.最后做了一个WinForm版的小聊天室.这个聊天室的客户端和服务端都只是在本机上运行. 这里我首先和大家谈谈我对聊天室的一点理解,聊天室其实是服务端 ...
- AMAZON PRICE TRACKER, AMAZON PRICE HISTORY, AMAZON PRICE DROP ALERT | DROPGG.COM
DropGG.com is the destination for savvy shoppers looking to save money by buying smart. DropGG.com a ...
- 如何判断一个Div是否在可视区域,判断div是否可见
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- github配置和git学习
参考:http://www.eoeandroid.com/thread-272837-1-1.html http://blog.csdn.net/hcbbt/article/details/11651 ...
- Sencha Touch Guide
1.一些命令 创建APP # Make sure the current working directory is the Sencha Touch 2 SDK 例如D:\Program File ...
- 怎样清除td和input之间空隙
<style> input {background:red;border:none;height:30px;margin:0px} td {background-color:blue;pa ...
- python入门 第二天笔记
程序主文件标志if __name__=="__main__": 在程序执行python 1.py 时候 程序1.py __name__ 为 main调用其他文件是,__name__ ...
- Accessing Scoped Variables
To permit the JSP page to access the data, the servlet needs to use setAttribute to store the data i ...
- the apply of backbone
http://www.developer.com/print/lang/jscript/creating-a-javascript-driven-online-notebook-with-backbo ...
- 【良心noip膜你赛】总结
一点都不良心!!!! AK 快乐爆零快乐!!! 1. A. value512mb 1s规定一个区间的价值为这个区间中所有数 and 起来的值与这个区间所有数 or 起来的值的乘积.例如 3 个数 2, ...