WUSTOJ 1190: 零起点学算法97——A == B ?

Description

Give you two integer numbers A and B, if A is equal to B, you should print “YES”, or print “NO”.

Input

each test case contains two integer numbers A and B.

Output

for each case, if A is equal to B, you should print “YES”, or print “NO”.

Sample Input

  1. 1 2
  2. 2 2
  3. 3 3
  4. 4 3

Sample Output

  1. NO
  2. YES
  3. YES
  4. NO

HINT

注意A、B数位最多100位。

代码

  1. /**
  2. * 用时:472ms
  3. * @author wowpH
  4. * @version A1.1
  5. * @date 2019年4月13日 下午9:35:04
  6. */
  7. import java.math.BigInteger;
  8. import java.util.Scanner;
  9. public class Main {
  10. private Scanner sc;
  11. private BigInteger A, B;
  12. public Main() {
  13. sc = new Scanner(System.in);
  14. while(sc.hasNext()) {
  15. A = sc.nextBigInteger();
  16. B = sc.nextBigInteger();
  17. if(A.equals(B)) {
  18. System.out.println("YES");
  19. } else {
  20. System.out.println("NO");
  21. }
  22. }
  23. sc.close();
  24. }
  25. public static void main(String[] args) {
  26. new Main();
  27. }
  28. }

我为什么没有早点发现这个大数类(BigInteger),这么好用的一个类。

        虽然上面代码是正确的的,但是我想知道为什么下面这个就不行呢?

double 的表示范围是:1.7976931348623157e+308 这个为什么不行呢?

  1. /**
  2. * 提交:Wrong Answer
  3. * @author wowpH
  4. * @version A1.0
  5. * @date 2019年4月13日 下午9:35:04
  6. */
  7. import java.util.Scanner;
  8. public class Main {
  9. private Scanner sc;
  10. private double A, B;
  11. public Main() {
  12. sc = new Scanner(System.in);
  13. while(sc.hasNext()) {
  14. A = sc.nextDouble();
  15. B = sc.nextDouble();
  16. if(A == B) {
  17. System.out.println("YES");
  18. } else {
  19. System.out.println("NO");
  20. }
  21. }
  22. sc.close();
  23. }
  24. public static void main(String[] args) {
  25. new Main();
  26. }
  27. }

1190: 零起点学算法97——A == B ?(Java)的更多相关文章

  1. Problem E: 零起点学算法97——进制转换

    #include<stdio.h> int main(){ ]; while(scanf("%d%d",&n,&r)!=EOF){ ,i=; ){ fl ...

  2. 1164: 零起点学算法71——C语言合法标识符(存在问题)

    1164: 零起点学算法71——C语言合法标识符 Time Limit: 1 Sec  Memory Limit: 64 MB   64bit IO Format: %lldSubmitted: 10 ...

  3. 1163: 零起点学算法70——Yes,I can!

    1163: 零起点学算法70--Yes,I can! Time Limit: 1 Sec  Memory Limit: 64 MB   64bit IO Format: %lldSubmitted: ...

  4. 1147: 零起点学算法54——Fibonacc

    1147: 零起点学算法54--Fibonacc Time Limit: 1 Sec  Memory Limit: 64 MB   64bit IO Format: %lldSubmitted: 20 ...

  5. 1145: 零起点学算法52——数组中删数II

    1145: 零起点学算法52--数组中删数II Time Limit: 1 Sec  Memory Limit: 64 MB   64bit IO Format: %lldSubmitted: 293 ...

  6. 1137: 零起点学算法44——多组测试数据输出II

    1137: 零起点学算法44--多组测试数据输出II Time Limit: 1 Sec  Memory Limit: 64 MB   64bit IO Format: %lldSubmitted: ...

  7. 1136: 零起点学算法43——多组测试数据输出I

    1136: 零起点学算法43--多组测试数据输出I Time Limit: 1 Sec  Memory Limit: 128 MB   64bit IO Format: %lldSubmitted: ...

  8. 1135: 零起点学算法42——多组测试数据(求和)IV

    1135: 零起点学算法42--多组测试数据(求和)IV Time Limit: 1 Sec  Memory Limit: 64 MB   64bit IO Format: %lldSubmitted ...

  9. 1134: 零起点学算法41——多组测试数据(a+b)III

    1134: 零起点学算法41--多组测试数据(a+b)III Time Limit: 1 Sec  Memory Limit: 64 MB   64bit IO Format: %lldSubmitt ...

随机推荐

  1. enablePullDownRefresh的使用

    1.首先要在app.json里面去将enablePullDownRefresh设置为true. 2.js 3.现象

  2. 数据结构Java版之排序算法(二)

    排序按时间复杂度和空间复杂度可分为 低级排序 和 高级排序 算法两种.下面将对排序算法进行讲解,以及样例的展示. 低级排序:冒泡排序.选择排序.插入排序. 冒泡排序: 核心思想,小的数往前移.假设最小 ...

  3. [转]js创建1-100的数组

    //实现方法一:循环赋值var arr1 = new Array(100);for(var i=0;i<arr1.length;i++){ arr1[i] = i;}console.log(ar ...

  4. sqlserver 触发器实例

    实例1:update USE [数据库名称]GO/****** Object: Trigger [dbo].[触发器名称] Script Date: 05/08/2014 12:40:25 ***** ...

  5. 续--Flask, Django - 区别

    1. 目录结构         参考:https://blog.csdn.net/yang9520/article/details/79740374 中文文档(http://docs.jinkan.o ...

  6. HTML5Audio/Video全解(疑难杂症)

    1.mp4格式视频无法在chrome中播放 Chrome浏览器支持HTML5,它支持原生播放部分的MP4格式(不用通过Flash等插件).为 什么是部分MP4呢?MP4有非常复杂的含义(见http:/ ...

  7. 25.Flutter中的表单 Radio RadioListTile Switch SwitchListTile 以及表单组件实现一个简单的学员登记系统(下)

    四.Radio.RadioListTile单选按钮组件 Radio常用属性: value单选的值. onChanged改变时触发. activeColor:选中的颜色.背景颜色 groupValue: ...

  8. ES6 Syntax and Feature Overview

    View on GitHub Note: A commonly accepted practice is to use const except in cases of loops and reass ...

  9. java递归删除目录下所有内容

    java递归删除目录下所有内容 private static boolean deleteDir(File dir) {if (dir.isDirectory()) {        String[] ...

  10. 重置密码解决MySQL for Linux

    重置密码解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor ...