zoukankan      html  css  js  c++  java
  • (stripTrailingZeros)A == B hdu2054

    A == B ?

    Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

    Total Submission(s): 117898    Accepted Submission(s): 18821

    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

    可以用java大数

    import java.math.BigDecimal;
    import java.util.Scanner;
    
    public class Main {
    
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            BigDecimal a;
            BigDecimal b;
            while(in.hasNextBigDecimal()) {
                a=in.nextBigDecimal();
                b=in.nextBigDecimal();
                a=a.stripTrailingZeros();           //去掉小数点后面多余的0.
                b=b.stripTrailingZeros();
                if(a.equals(b))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }
  • 相关阅读:
    iOS AutoLayout的用法
    UIPickerView的使用(一)
    UIPickerView的使用(二)
    logging模块
    configparser模块
    hashlib模块
    json & pickle 模块
    对表的操作
    表记录曾删改查
    库、表曾删改查和存储引擎
  • 原文地址:https://www.cnblogs.com/Weixu-Liu/p/9166469.html
Copyright © 2011-2022 走看看