1190: 零起点学算法97——A == B ?(Java)
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 2
2 2
3 3
4 3
Sample Output
NO
YES
YES
NO
HINT
注意A、B数位最多100位。
代码
/**
* 用时:472ms
* @author wowpH
* @version A1.1
* @date 2019年4月13日 下午9:35:04
*/
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
private Scanner sc;
private BigInteger A, B;
public Main() {
sc = new Scanner(System.in);
while(sc.hasNext()) {
A = sc.nextBigInteger();
B = sc.nextBigInteger();
if(A.equals(B)) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
sc.close();
}
public static void main(String[] args) {
new Main();
}
}
我为什么没有早点发现这个大数类(BigInteger),这么好用的一个类。
虽然上面代码是正确的的,但是我想知道为什么下面这个就不行呢?
double 的表示范围是:1.7976931348623157e+308 这个为什么不行呢?
/**
* 提交:Wrong Answer
* @author wowpH
* @version A1.0
* @date 2019年4月13日 下午9:35:04
*/
import java.util.Scanner;
public class Main {
private Scanner sc;
private double A, B;
public Main() {
sc = new Scanner(System.in);
while(sc.hasNext()) {
A = sc.nextDouble();
B = sc.nextDouble();
if(A == B) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
sc.close();
}
public static void main(String[] args) {
new Main();
}
}
1190: 零起点学算法97——A == B ?(Java)的更多相关文章
- Problem E: 零起点学算法97——进制转换
#include<stdio.h> int main(){ ]; while(scanf("%d%d",&n,&r)!=EOF){ ,i=; ){ fl ...
- 1164: 零起点学算法71——C语言合法标识符(存在问题)
1164: 零起点学算法71——C语言合法标识符 Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 10 ...
- 1163: 零起点学算法70——Yes,I can!
1163: 零起点学算法70--Yes,I can! Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: ...
- 1147: 零起点学算法54——Fibonacc
1147: 零起点学算法54--Fibonacc Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 20 ...
- 1145: 零起点学算法52——数组中删数II
1145: 零起点学算法52--数组中删数II Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 293 ...
- 1137: 零起点学算法44——多组测试数据输出II
1137: 零起点学算法44--多组测试数据输出II Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: ...
- 1136: 零起点学算法43——多组测试数据输出I
1136: 零起点学算法43--多组测试数据输出I Time Limit: 1 Sec Memory Limit: 128 MB 64bit IO Format: %lldSubmitted: ...
- 1135: 零起点学算法42——多组测试数据(求和)IV
1135: 零起点学算法42--多组测试数据(求和)IV Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted ...
- 1134: 零起点学算法41——多组测试数据(a+b)III
1134: 零起点学算法41--多组测试数据(a+b)III Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitt ...
随机推荐
- enablePullDownRefresh的使用
1.首先要在app.json里面去将enablePullDownRefresh设置为true. 2.js 3.现象
- 数据结构Java版之排序算法(二)
排序按时间复杂度和空间复杂度可分为 低级排序 和 高级排序 算法两种.下面将对排序算法进行讲解,以及样例的展示. 低级排序:冒泡排序.选择排序.插入排序. 冒泡排序: 核心思想,小的数往前移.假设最小 ...
- [转]js创建1-100的数组
//实现方法一:循环赋值var arr1 = new Array(100);for(var i=0;i<arr1.length;i++){ arr1[i] = i;}console.log(ar ...
- sqlserver 触发器实例
实例1:update USE [数据库名称]GO/****** Object: Trigger [dbo].[触发器名称] Script Date: 05/08/2014 12:40:25 ***** ...
- 续--Flask, Django - 区别
1. 目录结构 参考:https://blog.csdn.net/yang9520/article/details/79740374 中文文档(http://docs.jinkan.o ...
- HTML5Audio/Video全解(疑难杂症)
1.mp4格式视频无法在chrome中播放 Chrome浏览器支持HTML5,它支持原生播放部分的MP4格式(不用通过Flash等插件).为 什么是部分MP4呢?MP4有非常复杂的含义(见http:/ ...
- 25.Flutter中的表单 Radio RadioListTile Switch SwitchListTile 以及表单组件实现一个简单的学员登记系统(下)
四.Radio.RadioListTile单选按钮组件 Radio常用属性: value单选的值. onChanged改变时触发. activeColor:选中的颜色.背景颜色 groupValue: ...
- ES6 Syntax and Feature Overview
View on GitHub Note: A commonly accepted practice is to use const except in cases of loops and reass ...
- java递归删除目录下所有内容
java递归删除目录下所有内容 private static boolean deleteDir(File dir) {if (dir.isDirectory()) { String[] ...
- 重置密码解决MySQL for Linux
重置密码解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor ...