A/B problem

A/B Problem

时间限制: 1000 ms  |  内存限制: 65535 KB
难度: 3
描述

 做了A+B Problem,A/B Problem不是什么问题了吧!

输入
每组测试样例一行,首先一个号码A,中间一个或多个空格,然后一个符号( / 或者 % ),然后又是空格,后面又是一个号码B,A可能会很长,B是一个int范围的数。
输出
输出结果。
样例输入
110 / 100
99 % 10
2147483647 / 2147483647
2147483646 % 2147483647
样例输出
1
9
1

2147483646

思路:依旧是java大数类

 
import java.util.Scanner;
import java.math.BigInteger;
public class Main 
{
	public static void main(String[] args)
	{
		Scanner cin = new Scanner(System.in);
		BigInteger a, b;
		String s;
		while(cin.hasNext())
		{
		a = cin.nextBigInteger();
		s = cin.next();
		b = cin.nextBigInteger();
		if(s.equals("/"))
		{
			System.out.println(a.divide(b));
		}
		else
		{
			System.out.println(a.mod(b));
		}
		}
	}
}        


你可能感兴趣的:(java,类)