大数阶乘

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=28

 import java.io.*;
import java.util.*;
import java.math.*;
//import java.text.*; public class Main { /**
* @param args
*/
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
Scanner cin = new Scanner (System.in);
PrintWriter cout = new PrintWriter(System.out); int n = cin.nextInt();
BigInteger ans = BigInteger.ONE;
for(int i=1;i<=n;i++)
ans = ans.multiply(BigInteger.valueOf(i));
cout.println(ans);
cout.flush();
} }

比较大小

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=73

 import java.io.*;
import java.util.*;
import java.math.*;
import java.text.*; public class Main { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner cin = new Scanner(System.in);
while(true)
{
BigInteger a = cin.nextBigInteger();
BigInteger b = cin.nextBigInteger();
if(a.equals(BigInteger.ZERO) && b.equals(BigInteger.ZERO) )
{
break;
}
int flag = a.compareTo(b);
if(flag == 0)
System.out.println("a==b");
else if(flag == -1)
System.out.println("a<b");
else
System.out.println("a>b");
}
} }

大数加法

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=103

 import java.io.*;
import java.util.*;
import java.math.*; public class Main { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
int cas = 1;
for(int i=1;i<=T;i++)
{
BigInteger a = cin.nextBigInteger();
BigInteger b = cin.nextBigInteger();
BigInteger ans = a.add(b); System.out.println("Case "+i+":");
System.out.println(a+" + "+b+" = "+ans);
}
} }

Java大数练习的更多相关文章

  1. java大数

    java大数还是很好用的! 基本加入: import java.math.BigInteger; import jave.math.BigDecimal; 分别是大数和大浮点数. 首先读入可以用: S ...

  2. JAVA大数运算

    java大数是个好东西,用起来方便,代码短. 代码如下: import java.util.*; import java.math.*; public class Main { public stat ...

  3. java大数总结【转】

    java大数(2013长春网络赛)--hdu4762总结一下:1.java提交类要写Main.2.读取大数. Scanner read=new Scanner(System.in); BigInteg ...

  4. HDU5047Sawtooth(java大数)

    HDU5047Sawtooth(java大数) 题目链接 题目大意:在一个矩形内画n个"M".问如何画可以把这个矩形分成最多的区域. 给出这个区域的数目. 解题思路:最好的方式就是 ...

  5. JAVA大数类

    JAVA大数类api http://man.ddvip.com/program/java_api_zh/java/math/BigInteger.html#method_summary 不仅仅只能查J ...

  6. HDU4762(JAVA大数)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  7. ZOJ3477&JAVA大数类

    转:http://blog.csdn.net/sunkun2013/article/details/11822927 import java.util.*; import java.math.BigI ...

  8. 多校第五场 归并排序+暴力矩阵乘+模拟+java大数&amp;记忆化递归

    HDU 4911 Inversion 考点:归并排序 思路:这题呀比赛的时候忘了知道能够用归并排序算出逆序数,可是忘了归并排序的实质了.然后不会做-- 由于看到题上说是相邻的两个数才干交换的时候.感觉 ...

  9. 收藏的一段关于java大数运算的代码

    收藏的一段关于java大数运算的代码: package study_02.number; import java.math.BigDecimal; import java.math.BigIntege ...

  10. java大数判断相等

    java大数判断相等: 1.equals()方法2.compareTo()方法区别:2.00与2.0 equals()方法判断不等,compareTo()方法判断相等,科学的说法可以看java api ...

随机推荐

  1. 性能调优7:多表连接 - join

    在产品环境中,往往存在着大量的表连接情景,不管是inner join.outer join.cross join和full join(逻辑连接符号),在内部都会转化为物理连接(Physical Joi ...

  2. Linux stress 命令

    stress 命令主要用来模拟系统负载较高时的场景,本文介绍其基本用法.文中 demo 的演示环境为 ubuntu 18.04. 基本语法 语法格式:stress <options> 常用 ...

  3. Python学习第十篇——函数初步

    def make_album(name,album_name,song_nums = 1): dict_album = {name:[album_name]} if int(song_nums) &g ...

  4. 爬虫——xpath

    1.什么是xpath? Xpath,全称XML Path Language,即XML路径语言.它是一门在XML之后查找信息的语言,也同样适用于HTML文档的搜索.在做爬虫的时候,我们用XPath语言来 ...

  5. Proper usage of Java -D command-line parameters

    https://stackoverflow.com/questions/5045608/proper-usage-of-java-d-command-line-parameters https://c ...

  6. PHP单元测试PHPUnit

    配置说明 1.全局安装phpunit命令脚本 1 2 3 4 5 $ wget https://phar.phpunit.de/phpunit-7.0.phar $ chmod +x phpunit- ...

  7. [转帖]Docker的数据管理(volume/bind mount/tmpfs)

    Docker(十五)-Docker的数据管理(volume/bind mount/tmpfs) https://www.cnblogs.com/zhuochong/p/10069719.html do ...

  8. taro 与uni-app对比

    https://www.jianshu.com/p/03e08399587e   (copy)

  9. jQuery 事件 - triggerHandler() 方法

    定义和用法 triggerHandler() 方法触发被选元素的指定事件类型.但不会执行浏览器默认动作,也不会产生事件冒泡. triggerHandler() 方法与 trigger() 方法类似.不 ...

  10. Django项目目录介绍

    一个小问题: 什么是根目录:就是没有路径,只有域名..url(r'^$') 补充一张关于wsgiref模块的图片 一.MTV模型 Django的MTV分别代表: Model(模型):和数据库相关的,负 ...