1. import java.io.*;
  2. import java.math.BigInteger;
  3. import java.util.*;
  4.  
  5. public class Main {
  6. public static void main(String[] args)
  7. {
  8. BigInteger ans,Zero;
  9.  
  10. Zero = BigInteger.ZERO;
  11. ans = BigInteger.ZERO;
  12. Scanner cin = new Scanner(System.in);
  13. while(cin.hasNextBigInteger())
  14. {
  15. BigInteger temp = cin.nextBigInteger();
  16. if(temp.equals(Zero)) break;
  17. ans = ans.add(temp);
  18. }
  19. System.out.println(ans);
  20. }
  21. }
  1. import java.io.*;
  2. import java.math.BigInteger;
  3. import java.util.*;
  4.  
  5. public class Main {
  6. public static void main(String[] args)
  7. {
  8. BigInteger a,b;
  9.  
  10. Scanner cin = new Scanner(System.in);
  11.  
  12. while(cin.hasNextBigInteger())
  13. {
  14. a = cin.nextBigInteger();
  15. b = cin.nextBigInteger();
  16. System.out.println(a.multiply(b));
  17. }
  18.  
  19. }
  20. }
  1. import java.math.BigInteger;
  2. import java.util.*;
  3.  
  4. public class Main {
  5. public static void main(String[] args)
  6. {
  7. BigInteger a,b,c;
  8. String p,q;
  9. Scanner cin = new Scanner(System.in);
  10.  
  11. while(cin.hasNext())
  12. {
  13. p = cin.next();
  14. String s = cin.next();
  15. char ch = s.charAt(0);
  16. q = cin.next();
  17.  
  18. System.out.println(p+" "+s+" "+q);
  19. a = new BigInteger(p);
  20. b = new BigInteger(q);
  21.  
  22. if(ch == '+')
  23. c = a.add(b);
  24. else
  25. c = a.multiply(b);
  26.  
  27. if(a.bitLength() > 31)
  28. {
  29. System.out.println("first number too big");
  30. }
  31. if(b.bitLength() > 31)
  32. {
  33. System.out.println("second number too big");
  34. }
  35. if(c.bitLength() > 31)
  36. {
  37. System.out.println("result too big");
  38. }
  39. }
  40. }
  41. }

BigInteger Uva的更多相关文章

  1. uva 11357 Matches

    // uva 11357 Matches // // 题目大意: // // 给你n个火柴,用这n个火柴能表示的非负数有多少个,不能含有前导零 // // 解题思路: // // f[i] 表示正好用 ...

  2. UVa 10007 - Count the Trees(卡特兰数+阶乘+大数)

    题目链接:UVa 10007 题意:统计n个节点的二叉树的个数 1个节点形成的二叉树的形状个数为:1 2个节点形成的二叉树的形状个数为:2 3个节点形成的二叉树的形状个数为:5 4个节点形成的二叉树的 ...

  3. UVA 10254 十八 The Priest Mathematician

    The Priest Mathematician Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu ...

  4. UVa 11375 - Matches

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  5. BigInteger

    首先上模板(不断更新中...)(根据刘汝佳AOAPCII修改) #include <iostream> #include <sstream> #include <cstd ...

  6. uva 10007 Count the Trees

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  7. UVa 10213 - How Many Pieces of Land ?(欧拉公式)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  8. UVA 10328 - Coin Toss dp+大数

    题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_proble ...

  9. ACM中java中BigInteger和Decimal用到的主要函数

    java中大数以及高精度常用函数 使用java大数类解决问题时我们需要注意两个方面:1.不能有包名,也就是说我们要把主类放到默认的包里,如果你的代码里出现形如package cn.gov.test;这 ...

随机推荐

  1. MongoDB3.2版本与3.0版本写场景压力测试对比

    我们主要是为了测试journal对写操作性能的影响.分别测试了3.2版本,3.0版本在ramdisk,hdd上有journal,和没journal的情况. 发现一个很怪异的现象,3.2版本时候,随着y ...

  2. 移动端reset.css

    * { margin:; padding:; } article, aside, details, figcaption, figure, footer, header, hgroup, main, ...

  3. CSS3鼠标移入移出图片生成随机动画

    今天分享使用html+css3+少量jquery实现鼠标移入移出图片生成随机动画,我们先看最终效果图(截图为静态效果,做出来可是动态的哟) 左右旋转 上下移动 缩放 由于时间关系我就不一步步解析各段代 ...

  4. div 被Object盖住的。解决办法

    今天遇到一个比较头疼的问题,就是在一个标签上右键,弹出的菜单div被标签内的Office控件Object挡住了下半部分,始终无法显示.查了好多解决方案,最终都不能解决问题,几乎都要放弃了.中午吃饭的时 ...

  5. Windows API 常量定义

    Windows 常量定义在winuser.h中可以找到,如果了安装了visual studio 2010,winuser.h所在目录为C:\Program Files (x86)\Microsoft ...

  6. sql server 与C#数据类型对应表

  7. 使用ajax和history.pushState无刷新改变页面URL onpopstate(转)

    Javascript代码 var htmlData1 = $.ajax(    {    url: "/getXXXResponse",    async: false }).re ...

  8. C语言面向对象的简便方法

    都知道C语言是面向过程的,但是现在软件规模越来越大,通过面向对象的方式可以简化开发.业余时间想了个简单的方法,在C中使用一部分面向对象的基本功能.由于C语言自身的限制,并不完善,只能将就用,聊胜于无, ...

  9. C#中数据库连接的配置文件

    在C#2010中,如何保存和访问数据库的连接字符串呢? 在Winform下要新增App.config文件,在Asp.net下要新增web.config文件. 1.打开配置文件添加相关代码后如下即可: ...

  10. Cloud Test 在手,宕机时让您不再措手不及

    1月28日,Github 上午 10:04 分宕机了,导致全球各地的用户不能访问.官方回复可能是网络中断引起的,到 10:28 分已经可以正常访问. 对于互联网公司来说,一旦宕机就会措手不及,如何才能 ...