-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1060.cpp
63 lines (59 loc) · 1.14 KB
/
1060.cpp
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// 1060.cpp
// 算法
//
// Created by 王怡凡 on 2017/3/27.
// Copyright © 2017年 王怡凡. All rights reserved.
//
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
int n;
string a,b,s3,s4;
string deal(string s ,int& e) {
int k=0;
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;
}
int num = 0;
k=0;
string res;
while(num<n) {
if(k<s.length()) res+=s[k++];
else res += '0';
num++;
}
return res;
}
int main() {
scanf("%d",&n);
cin >> a >> b;
int e1=0,e2=0;
s3 = deal(a,e1);
s4 = deal(b,e2);
if(s3==s4&&e1==e2) {
cout << "YES 0."<< s3 << "*10^"<<e1 << endl;
}else {
cout << "NO 0."<<s3<<"*10^"<<e1<<" 0."<<s4<<"*10^"<<e2<<endl;
}
return 0;
}