#include<cstdio>
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;
int n;
string str1,str2,str3,str4;
string change(string s,int &e)
{
e=0;
int k=0;
int num=0;
string res;
while(s.length()>0&&s[0]=='0')
{
s.erase(s.begin());
}
if(s[0]=='.')
{
s.erase(s.begin());
while(s.length()>0&&s[0]=='0')
{
s.erase(s.begin());
e--;
}
}
else
{
while(k<s.length()&&s[k]!='.')
{
k++;
e++;
}
if(k<s.length())
s.erase(s.begin()+k);
}
if(s.length()==0)
e=0;
k=0;
while(num<n)
{
if(k<s.length())
{
res=res+s[k++];
}
else
res=res+'0';
num++;
}
return res;
}
int main()
{
cin>>n>>str1>>str2;
int e1=0,e2=0;
str3=change(str1,e1);
str4=change(str2,e2);
if(e1==e2&&str3==str4)
{
cout<<"YES "<<"0."<<str3<<"*10^"<<e1;
}
else
{
cout<<"NO "<<"0."<<str3<<"*10^"<<e1<<" 0."<<str4<<"*10^"<<e2;
}
system("pause");
return 0;
}
PAT 1060
最新推荐文章于 2023-01-30 21:00:00 发布