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 ...
随机推荐
- ROS launch 总结
ROS launch 总结 转自博客:https://www.cnblogs.com/Jessica-jie/p/6961837.html 1 运行Launch文件2 新建Launch文件3 在na ...
- kubernetes使用本地仓库
k8s与docker的安装 我参考的是 https://kuboard.cn/install/install-k8s.html#%E6%96%87%E6%A1%A3%E7%89%B9%E7%82%B9 ...
- scanf和fgets比较
scanf 长度限制 #include<stdio.h> int main() { char food[5]; printf("Enter food"); scanf( ...
- jquery报变量没定义错误的原因
该变量定义的范围:不在使用的方法中:
- [软工]Github的使用
注册 修改个人信息 fork项目 使用github客户端 commit项目 发送PR 注意事项 不要使用上述项目进行试验 建议Github用户名有规律,好记忆
- TynSerial类介绍
TynSerial类介绍 TynSerial是咏南中间件封装的,支持数据二进制序列(还原)的类. 支持WINDOWS.LINUX.MAC.IOS.ANDROID. 支持D6及以上版本. 支持TCP/H ...
- Send me - PLANETSHAKERS
Send me i will go 送我,我会去 send me i will go 送我,我会 to this city, to this nations 为这城市 为这国家 and to th ...
- Java 签名(SHA1WithRSA、SHA256WithRSA、SHA256withECDSA)
RSA1.RSA256 签名 public static String MakeSign(String Data) { try { byte[] data = Data.getBytes(); byt ...
- int 和String之间的相互转换
int ---> String 1. 和 "" 进行拼接 2. 使用String类中的静态方法valueOf: public static String valueOf(in ...
- Oracle 表的行数、表占用空间大小,列的非空行数、列占用空间大小 查询
--表名,表占用空间大小(MB),行数select table_name, round(num_rows * avg_row_len /1024/1024, 8) as total_len, num_ ...