HDU-2054-A == B?(Java大数BigDecimal)

A == B ?

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

Total Submission(s): 72556    Accepted Submission(s): 11427

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

Author

8600 && xhd

Source

校庆杯Warm Up

Recommend

linle   |   We have carefully selected several similar problems for you:  2057 2050 1096 1091 2074

比起c选手,只有在做大数的时候,有一种自然而然的优越感

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

public class Main
{

	public static void main(String[] args)
	{
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		while(input.hasNext())
		{
			BigDecimal a = input.nextBigDecimal();
			BigDecimal b = input.nextBigDecimal();
			if(a.compareTo(b)!=0)
			{
				System.out.println("NO");
			}
			else
			{
				System.out.println("YES");
			}
		}
	}

}
时间: 2024-10-07 12:40:25

HDU-2054-A == B?(Java大数BigDecimal)的相关文章

hdu 2054 A == B ? (java大数)

题目意思: http://acm.hdu.edu.cn/showproblem.php?pid=2054 给出两个数,判断是否相等,相等输出YES,否则输出NO. 题目分析: 注意题目给的是两个数,没有说明格式和大小,只能字符串模拟比较,或者java大数比较.这里给出java的大数比较. AC代码: import java.math.BigDecimal; import java.math.BigInteger; import java.util.Scanner; public class Ma

HDU 4927 Series 1 java大数

java mle前会wa 或者 t 这种事我会乱说? import java.math.*; import java.util.*; import java.io.*; public class Main { BigInteger[] a = new BigInteger[3007]; public void work() { int T; T = cin.nextInt(); while (T-- > 0) { int n; n = cin.nextInt(); for (int i = 0;

HDU高精度总结(java大数类)

  HDU1002   A + B Problem II [题意]大数相加 [链接]http://acm.hdu.edu.cn/showproblem.php?pid=1002 Sample Input 2 1 2 112233445566778899 998877665544332211 Sample Output Case 1: 1 + 2 = 3 Case 2: 112233445566778899 + 998877665544332211 = 1111111111111111110 代码

HDU 5047 Sawtooth (JAVA大数类)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5047 题面: Sawtooth Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1636    Accepted Submission(s): 637 Problem Description Think about a plane: ● O

多校第六场 HDU 4927 JAVA大数类

题目大意:给定一个长度为n的序列a,每次生成一个新的序列,长度为n-1,新序列b中bi=ai+1?ai,直到序列长度为1.输出最后的数. 思路:这题实在是太晕了,比赛的时候搞了四个小时,从T到WA,唉--对算组合还是不太了解啊,现在对组合算比较什么了-- import java.io.*; import java.math.*; import java.util.*; public class Main { public static void main(String[] args) { Sca

Java大数处理类:BigInteger类和BigDecimal类

当我们要处理非常大的数据时,平常用的数据类型已不足以表示,在Java中有两个类BigInteger和BigDecimal分别表示大整数类和大浮点数类,这两个类在理论上只要计算机内存足够大就能够表示无线大的数.它们都在java.math.*包中,我们可以在API文档中进行查看: Java API 1.6 中文在线帮助文档 http://www.yq1012.com/api/ 实例: 1 import java.math.BigDecimal; 2 import java.math.BigInteg

HDU Exponentiation 1063 Java大数题解

Exponentiation Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6973    Accepted Submission(s): 1975 Problem Description Problems involving the computation of exact values of very large magnitude

HDU 1250 Hat's Fibonacci(Java大数相加)+讲解

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1250 Problem Description A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1. F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n -

HDU 4919 打表找规律 java大数 map 递归

== oeis: 点击打开链接 瞎了,x.mod(BigInteger.ValueOf(2)).equal( BigInteger.ValueOf(1)) 写成了 x.mod(BigInteger.ValueOf(2)).equal( 1 ) T^T100块没了... import java.math.*; import java.util.*; import static java.lang.System.out; import java.io.*; public class Main { s