oj上java大数的使用

import java.math.BigInteger;
import java.util.Scanner;

public class Main {//类名要用Main
    public static void main(String[] args){
        
        int T;
        BigInteger N,M;
        BigInteger MOD=new BigInteger("11");
        BigInteger ZERO=new BigInteger("0");
        Scanner sc=new Scanner(System.in);
        
        T=sc.nextInt();
        while((T--)>0){
            
            N=sc.nextBigInteger();
            M=sc.nextBigInteger();
            
            if(N.compareTo(M)==0&&N.mod(MOD).compareTo(ZERO)==0){//
                System.out.println("YES");
            }
            else{//
                System.out.println("NO");
            }
            
        }
        
    }
}
View Code

ps:取余最好用remainder,mod好像mod负数报错

原文地址:https://www.cnblogs.com/gongpixin/p/5497303.html