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;这 ...
随机推荐
- MongoDB3.2版本与3.0版本写场景压力测试对比
我们主要是为了测试journal对写操作性能的影响.分别测试了3.2版本,3.0版本在ramdisk,hdd上有journal,和没journal的情况. 发现一个很怪异的现象,3.2版本时候,随着y ...
- 移动端reset.css
* { margin:; padding:; } article, aside, details, figcaption, figure, footer, header, hgroup, main, ...
- CSS3鼠标移入移出图片生成随机动画
今天分享使用html+css3+少量jquery实现鼠标移入移出图片生成随机动画,我们先看最终效果图(截图为静态效果,做出来可是动态的哟) 左右旋转 上下移动 缩放 由于时间关系我就不一步步解析各段代 ...
- div 被Object盖住的。解决办法
今天遇到一个比较头疼的问题,就是在一个标签上右键,弹出的菜单div被标签内的Office控件Object挡住了下半部分,始终无法显示.查了好多解决方案,最终都不能解决问题,几乎都要放弃了.中午吃饭的时 ...
- Windows API 常量定义
Windows 常量定义在winuser.h中可以找到,如果了安装了visual studio 2010,winuser.h所在目录为C:\Program Files (x86)\Microsoft ...
- sql server 与C#数据类型对应表
- 使用ajax和history.pushState无刷新改变页面URL onpopstate(转)
Javascript代码 var htmlData1 = $.ajax( { url: "/getXXXResponse", async: false }).re ...
- C语言面向对象的简便方法
都知道C语言是面向过程的,但是现在软件规模越来越大,通过面向对象的方式可以简化开发.业余时间想了个简单的方法,在C中使用一部分面向对象的基本功能.由于C语言自身的限制,并不完善,只能将就用,聊胜于无, ...
- C#中数据库连接的配置文件
在C#2010中,如何保存和访问数据库的连接字符串呢? 在Winform下要新增App.config文件,在Asp.net下要新增web.config文件. 1.打开配置文件添加相关代码后如下即可: ...
- Cloud Test 在手,宕机时让您不再措手不及
1月28日,Github 上午 10:04 分宕机了,导致全球各地的用户不能访问.官方回复可能是网络中断引起的,到 10:28 分已经可以正常访问. 对于互联网公司来说,一旦宕机就会措手不及,如何才能 ...