ACM JAVA大数

有的水题自己模拟下大数就过了,有的各种坑,天知道曾经因为大数wa了多少次....自己最近学者用JAVA,下面是自己总结的JAVA常用知识..


框架


import java.util.Scanner;
import java.math.*;


public class Main
{
   public static void main(String args[])
   {




    }
}


输入输出
Scanner cin = new Scanner(System.in);
int t = cin.nextInt();  //输入 int t
BigInteger m = cin.nextBigInteger();//输入 bigint m 
(实数是BigDecimal)
String s; s = cin.next();//串char op = s.charAt(0);


System.out.println();输出




类型转换
BigInteger tmp=BigInteger.valueOf(n);//整数
BigDecimal tmp=BigDecimal.valueOf(n);//实数
s = a.toString();//字符串


基本函数


1.valueOf(parament); 将参数转换为制定的类型  
2.add(); 大整数相加
3.subtract(); 相减
4.multiply(); 相乘
5.divide();    相除取整
6.remainder();取余
7.pow();   a.pow(b)=a^b
8.gcd();   最大公约数
9.abs(); 绝对值
10.negate();取反数
11.mod(); a.mod(b)=a%b=a.remainder(b);
12.max(); min();
13.punlic int comareTo();
14.boolean equals(); 是否相等




基本常量


A=BigInteger.ONE    1


B=BigInteger.TEN    10


C=BigInteger.ZERO   0


原文地址:https://www.cnblogs.com/csnd/p/12063282.html