#include <iostream>
#include <string>
using namespace std;
class CA
{
public:
void run();
void trantoformat(string &ss,int &nn);
int n;
string s1,s2,szero;
};
void CA::trantoformat(string &ss,int &nn)
{
string tmp=szero;
int i,j,pointpos,firstdigit;
pointpos=0;
pointpos=ss.find('.');
if(pointpos<0) pointpos=ss.length();
i=0;
while(i<pointpos&&ss[i]=='0') i++;
if(i<pointpos)
{
nn=pointpos-i;
firstdigit=i;
}
else
{
j=pointpos+1;
while(j<ss.length()&&ss[j]=='0') j++;
firstdigit=j;
if(j<ss.length()) nn=-(j-pointpos-1);
else nn=0;
}
i=firstdigit;
j=0;
while(j<tmp.length()&&i<ss.length())
{
if(ss[i]=='.') {i++;continue;}
tmp[j]=ss[i];
j++;i++;
}
ss=tmp;
}
void CA::run()
{
cin>>n>>s1>>s2;
int n1,n2;
szero=string(n,'0');
trantoformat(s1,n1);
trantoformat(s2,n2);
if(n1==n2&&s1==s2)
{
printf("YES 0.%s*10^%d\n",s1.c_str(),n1);
}
else
{
printf("NO 0.%s*10^%d ",s1.c_str(),n1);
printf("0.%s*10^%d\n",s2.c_str(),n2);
}
}
int main()
{
// freopen("test.in","r",stdin);
CA *a=new CA;
a->run();
return 0;
}
1060. Are They Equal (25)
最新推荐文章于 2019-07-18 09:32:00 发布