码迷,mamicode.com
首页 > 编程语言 > 详细

nyoj 803 A/B Problem 【Java大数】

时间:2014-09-06 23:52:04      阅读:488      评论:0      收藏:0      [点我收藏+]

标签: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大数】

标签:java   大数   

原文地址:http://blog.csdn.net/shengweisong/article/details/39105685

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!