首页 > 代码库 > nyoj 803 A/B Problem 【Java大数】

nyoj 803 A/B Problem 【Java大数】

 先用字符串将字符串接收,然后在用BigInteger就好了

代码:

import java.util.Scanner;
import java.math.*;
public class Main{
	public static void main(String[] args){
		Scanner cin = new Scanner(System.in);
		while(cin.hasNextBigInteger()){
			BigInteger aa, bb;
			//a = cin.nextBigDecimal();
			//b = cin.nextBigDecimal();
			String a, b, c;
			a = cin.next();
			b = cin.next();
			c = cin.next();
			aa = new BigInteger(a);
			bb = new BigInteger(c);
			//System.out.println(a);
			//System.out.println(b);
			//System.out.println(c);
			if(b.compareTo("/") == 0) System.out.println(aa.divide(bb));
			if(b.compareTo("%") == 0){
				System.out.println(aa.mod(bb));
			}
			//else System.out.println("NO");
		}
	}
}        

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

nyoj 803 A/B Problem 【Java大数】