码迷,mamicode.com
首页 > 其他好文 > 详细

A/B Problem

时间:2014-11-30 22:56:53      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   ar   color   os   sp   java   on   

描述

 做了A+B Problem,A/B Problem不是什么问题了吧!bubuko.com,布布扣

 
输入
每组测试样例一行,首先一个号码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             

 

 

A/B Problem

标签:style   blog   http   ar   color   os   sp   java   on   

原文地址:http://www.cnblogs.com/zqxLonely/p/4133691.html

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