模拟题。坑点较多。

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<map>
#include<queue>
#include<string>
#include<stack>
#include<vector>
using namespace std; int n;
string s,t;
struct X
{
string f;
int idx;
} ans[]; string change(string a)
{
string res;
if(a.length()-<n)
{
for(int i=a.length()-;i<n;i++) a=a+"";
res=a;
} else if(a.length()->n)
{
res="0.";
for(int i=;i<n+;i++) res=res+a[i];
}
else res=a;
return res;
} string qu(string a)
{
string res;
if(a.length()==&&a[]=='') return a; int pos=-;
for(int i=; i<a.length(); i++) if(a[i]=='.') pos=i; if(pos==-)
{
for(int i=; i<a.length(); i++)
{
if(a[i]=='') continue;
else
{
for(int j=i; j<a.length(); j++) res=res+a[j];
break;
}
}
}
else
{
for(int i=; i<pos-; i++)
{
if(a[i]=='') continue;
else
{
for(int j=i; j<pos-; j++) res=res+a[j];
break;
}
}
for(int i=pos-; i<a.length(); i++) res=res+a[i];
} if(res.length()==) res="";
return res;
} void R(int a)
{
bool ling=;
for(int i=; i<ans[a].f.length(); i++)
{
if(ans[a].f[i]=='.') continue;
if(ans[a].f[i]!='') ling=;
} if(ling) ans[a].idx=;
} void PUT(int a)
{
cout<<ans[a].f<<"*10^"<<ans[a].idx;
} int main()
{
scanf("%d",&n);
cin>>s>>t; s=qu(s);
t=qu(t); if(s[]==''&&s[]=='.')
{
int num=;
for(int i=; i<s.length(); i++)
{
if(s[i]=='') num++;
else
{
ans[].idx=-num;
ans[].f="0.";
for(int j=i; j<s.length(); j++) ans[].f=ans[].f+s[j];
break;
}
}
if(ans[].f.length()==)
{
ans[].f="0.0";
ans[].idx=;
}
} else
{
int pos=-;
for(int i=; i<s.length(); i++) if(s[i]=='.') pos=i;
if(pos!=-)
{
ans[].f="0.";
for(int i=; i<s.length(); i++) if(s[i]!='.') ans[].f=ans[].f+s[i];
ans[].idx=pos;
}
else
{
ans[].f="0."+s;
ans[].idx=s.length();
}
} ans[].f=change(ans[].f); if(t[]==''&&t[]=='.')
{
int num=;
for(int i=; i<t.length(); i++)
{
if(t[i]=='') num++;
else
{
ans[].idx=-num;
ans[].f="0.";
for(int j=i; j<t.length(); j++) ans[].f=ans[].f+t[j];
break;
}
}
if(ans[].f.length()==)
{
ans[].f="0.0";
ans[].idx=;
}
}
else
{
int pos=-;
for(int i=; i<t.length(); i++) if(t[i]=='.') pos=i;
if(pos!=-)
{
ans[].f="0.";
for(int i=; i<t.length(); i++) if(t[i]!='.') ans[].f=ans[].f+t[i];
ans[].idx=pos;
}
else
{
ans[].f="0."+t;
ans[].idx=t.length();
}
} ans[].f=change(ans[].f); R(); R(); if(ans[].f==ans[].f&&ans[].idx==ans[].idx)
{
printf("YES ");
PUT();
} else
{
printf("NO ");
PUT();
cout<<" ";
PUT();
cout<<endl;
} return ;
}

PAT (Advanced Level) 1060. Are They Equal (25)的更多相关文章

  1. 【PAT甲级】1060 Are They Equal (25 分)(需注意细节的模拟)

    题意: 输入一个正整数N(<=100),接着输入两个浮点数(可能包含前导零,对于PAT已经习惯以string输入了,这点未知),在保留N位有效数字的同时判断两个数是否相等,并以科学计数法输出. ...

  2. PAT (Advanced Level) 1113. Integer Set Partition (25)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  3. PAT (Advanced Level) 1110. Complete Binary Tree (25)

    判断一棵二叉树是否完全二叉树. #include<cstdio> #include<cstring> #include<cmath> #include<vec ...

  4. PAT (Advanced Level) 1094. The Largest Generation (25)

    简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...

  5. PAT (Advanced Level) 1074. Reversing Linked List (25)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  6. PAT (Advanced Level) 1062. Talent and Virtue (25)

    简单排序.题意较长. #include<cstdio> #include<cstring> #include<cmath> #include<queue> ...

  7. PAT (Advanced Level) 1056. Mice and Rice (25)

    简单模拟. #include<iostream> #include<cstring> #include<cmath> #include<algorithm&g ...

  8. PAT (Advanced Level) 1053. Path of Equal Weight (30)

    简单DFS #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...

  9. PAT (Advanced Level) 1052. Linked List Sorting (25)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

随机推荐

  1. 第三十五节,json数据类型转换字符串模块

    在使用json模块时需要先 import json 引入模块 json.dumps()模块函数 功能:将Python数据类型转换成字符串[有参] 使用方法:json.dumps(要转换的数据类型变量) ...

  2. 解析JSON对象与字符串之间的相互转换

    在开发的过程中,如果对于少量参数的前后台传递,可以直接采用ajax的data函数,按json格式传递,后台Request即可,但有的时候,需要传递多个参数,这样后台 接受的时候Request多个很麻烦 ...

  3. 【转】Ecshop 后台增加一个左侧列表菜单menu菜单的方法

    cshop 后台增加一个左侧列表菜单menu菜单需要修改三个文件:/admin/includes/inc_menu.php/admin/includes/inc_priv.php/languages/ ...

  4. PreferenceActivity详解

    为了引入这个概率 首先从需求说起 即:现有某Activity专门用于手机属性设置 那么应该如何做呢? 根据已学知识 很快一个念头闪过 即:Activity + Preference 组合 前者用于界面 ...

  5. 尚未配置为Web项目.指定的本地IIS URL http://localhsst/..要打开项目,需要配置虚拟目录 。是否立即创建虚拟目录 解决

    1.编辑.csproj文件 2.修改 UseIIS节点改为false,再次打开程序即可

  6. “Installation error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED”

    1. 有可能你的客户端已经安装过了,需要移调才能安装2. 你的清单文件AndroidManifest.xml写的有问题,检查一下

  7. 编程实现Windows瞬间关机

    我们先来看看Windows正常的关机流程:①关机指令通知Windows子系统csrss.exe,csrss.exe收到通知后会和Winlogon.exe做一个数据交换,再由Winlogon.exe通知 ...

  8. SVN-svn path not found: 404 Not Found

    报错信息是本地找不到文件 因为我直接移动了项目中的java文件到别的目录,在SVN看来相当于变相的删掉了一个目录的文件,在另外一个目录新增文件, 但是移动文件SVN是不会做删除记录到日志文件中的,所以 ...

  9. 转 由一次磁盘告警引发的血案:du 和 ls 的区别

    如果你完全不明白或者完全明白图片含义, 那么你不用继续往下看了. 否则, 这篇文章也许正是你需要的. 背景 确切地说,不是收到的自动告警短信或者邮件告诉我某机器上的磁盘满了,而是某同学人肉发现该机器写 ...

  10. .bash_profile和.bashrc的什么区别

    /etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.并从/etc/profile.d目录的配置文件中搜集shell的设置./etc/bashrc:为每一个运 ...