zoukankan      html  css  js  c++  java
  • 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


  • 相关阅读:
    为什么 "auto a = 1;" 在C语言中可以编译通过?
    谈谈duilib
    软工第一次作业
    数独_个人项目
    统计Github项目信息
    字符串中的匹配之递归
    软工第0次作业
    c++浅拷贝与深拷贝(LeetCode669)
    修改xcode初始生成代码
    树上处理的问题总结
  • 原文地址:https://www.cnblogs.com/csnd/p/12063282.html
Copyright © 2011-2022 走看看