[HDU] 2054 -A == B ?
来源:互联网 发布:软件的盈利模式 编辑:程序博客网 时间:2024/06/03 15:36
一切不给数据范围的题目都是在耍流氓
A == B ?
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 109431 Accepted Submission(s): 17507
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 22 23 34 3
Sample Output
NOYESYESNO
Author
8600 && xhd
Source
校庆杯Warm Up
Recommend
linle
新生群里一个学生问的题目,给你两个数字A,B,问是否这两个数字相等
第一反应是水题。
第二反应还是水题。
第三反应是这题没给数据范围和类型,又有人问
肯定有坑
然后第三反应是直接字符串刚过去
WA之
然后这题很明显就是出题人耍流氓。
前导零和小数点后零的判断
还有当小数点后全是0的时候要把小数点也给去了。
3Y
感觉自己代码写得不太优雅
#include <bits/stdc++.h>using namespace std;int main(){ ios::sync_with_stdio(false); string ma; string mb; int mark; int flag1; int flag2; int be1, be2; int en1, en2; while(cin >> ma >> mb){ mark = 0; flag1 = 0; ///前导零 flag2 = 0; ///后导零 be1 = 0; be2 = 0; en1 = ma.size() - 1; en2 = mb.size() - 1; for(int i = 0; i < ma.size(); i ++){ if(ma[i] != '0'){ flag1 = 1; } if(!flag1){ be1 ++; } if(ma[i] == '.'){ flag2 = 1; } } if(flag2){ while(true){ if(ma[en1] != '0'){ break; } else{} en1 --; } } if(ma[en1] == '.'){ ///0.0 en1 --; } flag1 = 0; ///前导零 flag2 = 0; for(int i = 0; i < mb.size(); i ++){ if(mb[i] != '0'){ flag1 = 1; } if(!flag1){ be2 ++; } if(mb[i] == '.'){ flag2 = 1; } } if(flag2){ while(true){ if(mb[en2] != '0'){ break; } else{ en2 --; } } } if(mb[en2] == '.'){ en2 --; } //cout << be1 << ' ' << en1 << endl; //cout << be2 << ' ' << en2 << endl; if(en2 - be2 != en1 - be1){ mark = 1; } while(be1 <= en1 && be2 <= en2){ if(ma[be1] != mb[be2]){ mark = 1; break; } be1 ++; be2 ++; } if(mark){ cout << "NO" << endl; } else{ cout << "YES" << endl; } } return 0;}
阅读全文
0 0
- HDU 2054 A == B ?
- HDU 2054 A==B
- hdu acm 2054 A == B ?
- hdu - 2054 - A == B ?
- hdu 2054 A == B ?
- Hdu 2054 - A == B ?
- hdu 2054 A == B ?【JAVA】
- hdu 2054 A==B?
- HDU 2054 A == B ?
- hdu 2054 A==B?
- hdu 2054 A == B ?
- HDU--2054 -- A == B ? [字符串]
- HDU 2054 - A == B ?
- HDU 2054 A == B ?
- HDU-2054 A==B?
- HDU 2054 A==B? 大数
- HDU 2054 A == B ?
- hdu 2054A == B ?
- 单例模式
- .net 简易数据库操作框架1.6
- Linux多线程──3个子线程轮流运行
- add(int index, E element) 在列表的指定位置插入元素
- day58:hibernate04_JPA注解方式实现hibernate CRUD--【用户添加角色没那摩神秘】
- [HDU] 2054 -A == B ?
- 【HDU4336】Card Collector-状态压缩DP+期望DP
- python绘图实践-泰坦尼克号绘图
- 设计模式系列之「状态模式」
- Http和Https的简单理解
- Java单例模式
- LeetCode Algorithm #9 Palindrome Number
- 批量创建消息队列
- uploadify