(stripTrailingZeros)A == B hdu2054
Posted weixu-liu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了(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"); } } }
以上是关于(stripTrailingZeros)A == B hdu2054的主要内容,如果未能解决你的问题,请参考以下文章