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

HDOJ_ACM 2054 使用java

时间:2014-11-27 20:29:03      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:des   blog   io   ar   使用   sp   java   for   on   

Problem Description
Give you two numbers A and B, if A is equal to B, you should print "YES", or print "NO".
 
Input
each test case contains two numbers A and B.
 
Output
for each case, if A is equal to B, you should print "YES", or print "NO".
 
Sample Input
1 2 2 2 3 3 4 3
 
Sample Output

NO

YES

YES

NO

 

这道题应该考虑到小数,大数,0050,50 等等这些情况 用C语言或者C++会比较麻烦

但是在Java中有 BigDeimal 正好解决这个问题 (ACM可以用JAVA提交)

代码如下:

import java.util.*;
import java.math.BigDecimal;

public class Main
{
        public static void main(String args[])
       {
              BigDecimal a,b;
           Scanner in=new Scanner(System.in);
           while(in.hasNextBigDecimal())
           {
                  a=in.nextBigDecimal();
                  b=in.nextBigDecimal();
                  if(a.compareTo(b)==0) System.out.println("YES");
                  else System.out.println("NO");
           }
          
       }
}

  

 

HDOJ_ACM 2054 使用java

标签:des   blog   io   ar   使用   sp   java   for   on   

原文地址:http://www.cnblogs.com/tianyong/p/4127008.html

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