HD-ACM算法专攻系列(4)——A == B ?
题目描述:

源码:
/**/
#include"iostream"
#include"string"
using namespace std; string Standard(string str)
{
int start;
int len = str.length();
char * p = new char[len + 2];
start = 0;
if(str[0] == '-' || str[0] == '+')
{
p[0] = str[0];
start = 1;
}
else
{
p[0] = '+';
}
for(int i = start; i < len; i++)
{
if(str[i] == '0')
{
start++;
}
else
{
break;
}
}
bool hasDot = false;
for(int i = start; i < len; i++)
{
if(str[i] == '.')
{
hasDot = true;
break;
}
}
if(hasDot)
{
for(int i = len - 1; i >= start; i--)
{
if(str[i] == '0')
{
len--;
}
else
{
break;
}
}
}
int index = 1;
if(str[len - 1] == '.')
{
len--;
}
for(int i = start; i < len; i++)
{
p[index++] = str[i];
}
p[index] = '\0';
return string(p);
} int main()
{
string a, b;
while(cin>>a>>b)
{
a = Standard(a);
b = Standard(b);
if(a == b)
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
} }
return 0;
}
HD-ACM算法专攻系列(4)——A == B ?的更多相关文章
- HD-ACM算法专攻系列(23)——Crixalis's Equipment
题目描述: AC源码:此次考察贪心算法,解题思路:贪心的原则是使留下的空间最大,优先选择Bi与Ai差值最大的,至于为什么?这里用只有2个设备为例,(A1,B1)与(A2,B2),假设先搬运A1,搬运的 ...
- HD-ACM算法专攻系列(21)——Wooden Sticks
题目描述: AC源码: 此题考查贪心算法,解题思路:首先使用快速排序,以w或l按升序排序(注意相等时,应按另一值升序排序),这样就将二维变量比较,变为了一维的,排好序的一边就不需要去管了,只需要对未排 ...
- HD-ACM算法专攻系列(22)——Max Sum
问题描述: AC源码: 此题考察动态规划,解题思路:遍历(但有技巧),在于当前i各之和为负数时,直接选择以第i+1个为开头,在于当前i各之和为正数时,第i个可以不用作为开头(因为前i+1个之和一定大于 ...
- HD-ACM算法专攻系列(20)——七夕节
问题描述: AC源码: /**/ #include"iostream" #include"cmath" using namespace std; int mai ...
- HD-ACM算法专攻系列(19)——Leftmost Digit
问题描述: AC源码: 解题关键是,数据很大,不能强算,需要使用技巧,这里使用科学计算法,令N^N=a*10^n ,取对数后变为 N*log10(N)=log10(a)+n,令x = log10(a) ...
- HD-ACM算法专攻系列(18)——Largest prime factor
题目描述: 源码: 需要注意,若使用cin,cout输入输出,会超时. #include"iostream" #include"memory.h" #defin ...
- HD-ACM算法专攻系列(17)——find your present (2)
题目描述: 源码: #include"iostream" #include"string" using namespace std; bool IsFirstH ...
- HD-ACM算法专攻系列(16)——考试排名
问题描述: 源码: 主要要注意输出格式. #include"iostream" #include"iomanip" #include"algorith ...
- HD-ACM算法专攻系列(15)——Quoit Design
问题描述: 源码: 经典问题——最近邻问题,标准解法 #include"iostream" #include"algorithm" #include" ...
- HD-ACM算法专攻系列(14)——find your present (2)
问题描述: 源码: #include"iostream" #include"algorithm" using namespace std; bool cmp(i ...
随机推荐
- Linux就该这么学 20181008(第十三章BIND)
参考链接https://www.linuxprobe.com Bind提供域名解析服务 DNS Domin Name Server 域名解析服务 功能模式 .正向解析,将域名解析为IP地址 .反向解析 ...
- 8.QList QMap QVariant
QList int main1(int argc, char *argv[]) { QApplication a(argc, argv); QList<,,}; mylist << ...
- Android截图<包括Alertdiaog>
1.使用的系统内部的截屏方法…… 2. public class MainActivity extends AppCompatActivity { private static final Strin ...
- Javascript常用字符串判断函数
[代码] 字符串,函数,Javascript,脚本100 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ...
- Eclipse中执行Ant脚本出现Could not find the main class的问题及解
试过了:https://blog.csdn.net/bookroader/article/details/2300337 但是不管用,偶然看到这篇没有直接关系的 https://blog.csdn.n ...
- CPU VS GPU
CPU VS GPU 关于绘图和动画有两种处理的方式:CPU(中央处理器)和GPU(图形处理器).在现代iOS设备中,都有可以运行不同软件的可编程芯片,但是由于历史原因,我们可以说CPU所做的工作都在 ...
- Spring、Spring MVC、MyBatis 整合文件配置详解
使用SSM框架做了几个小项目了,感觉还不错是时候总结一下了.先总结一下SSM整合的文件配置.其实具体的用法最好还是看官方文档. Spring:http://spring.io/docs MyBatis ...
- anaconda3安装pytorch【window10】
1.离线下载: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/ 在清华镜像软件站下载相应的版本,由于我之前安装了 ...
- thinkphp queue
composer create-project topthink/think composer require topthink/think-queue php think queue:work -- ...
- tensorflow之tf.slice()
转载:https://www.jianshu.com/p/71e6ef6c121b https://www.cnblogs.com/chamie/p/11073363.html def slice(i ...