-
Notifications
You must be signed in to change notification settings - Fork 0
/
A1060_2.cpp
53 lines (48 loc) · 865 Bytes
/
A1060_2.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
// 0000.000231
// 0123.000123
// 1234.123434 3
// 1234.123434 7
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int n;
string deal(string s,int &e){
int k=0; //k是工作指针
int count = 0; //统计一下小数点后面的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());
count--;//小数点后减
}
}
else{
while( k < s.length() && s[k] != '.'){
k++;
count++;//小数前加
}
if( k< s.length()) {
s.erase(s.begin()+k);
}
}
}
int main() {
string s1,s2,s3,s4;
int e1 = 0;
int e2 = 0;
cin >> n >> s1 >>s2;
s3 = deal(s1,e1);
s4 = deal(s2,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;
}