#include<algorithm>
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<map>
#define ll long long
using namespace std;
int n;
void get(string &s,int &exp)
{
int i;
for(i = 0;i<s.length();i++)if(s[i] == '.')break;
exp = i;
if(i!=s.length())s.erase(s.begin()+i);
for(i = 0;i<s.length()&&s[i] == '0';i++);
if(i == s.length())
{
s = "";
exp = 0;
}
else
{
s = s.substr(i,s.length()-i);
exp-=i;
}
while(s.length()<n)s+='0';
s = s.substr(0,n);
s = "0."+s;
}
int main()
{
string a,b;
while(cin>>n>>a>>b)
{
int exp1 = 0,exp2 = 0;
get(a,exp1);
get(b,exp2);
if(a == b&&exp1 == exp2)cout<<"YES "<<a<<"*10^"<<exp1<<endl;
else cout<<"NO "<<a<<"*10^"<<exp1<<" "<<b<<"*10^"<<exp2<<endl;
}
return 0;
}
PAT 1060 Are They Equal 暴力
最新推荐文章于 2019-08-19 23:38:41 发布