A/B Problem

描述

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

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

 1 import java.math.BigInteger;
 2 import java.util.Scanner;
 3 
 4 public class Main {
 5     public static void main(String[] args) {
 6         Scanner scanner=new Scanner(System.in);
 7         BigInteger a;
 8         String sign;
 9         BigInteger b;
10         
11         while(scanner.hasNext()){
12             a=scanner.nextBigInteger();
13             sign=scanner.next();
14             b=scanner.nextBigInteger();
15             
16             if(sign.compareTo("/")==0)
17                 System.out.println(a.divide(b));
18             else
19                 System.out.println(a.remainder(b));
20         }
21     }
22 }
23             
24             

 

 
posted @ 2014-11-30 21:16  zqxLonely  阅读(231)  评论(0编辑  收藏  举报