-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAre_They_Equal.cpp
51 lines (49 loc) · 990 Bytes
/
Are_They_Equal.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
#include <cmath>
#include <iostream>
int main()
{
int n;
double a, b;
std::cin >> n >> a >> b;
int i = -101;
while (true)
{
if (a / pow(10, i) < 1)
break;
i++;
}
int asize = i;
int x, y;
x = a / pow(10, (asize - n));
i = -101;
while (true)
{
if (b / pow(10, i) < 1)
break;
i++;
}
int bsize = i;
y = b / pow(10, (bsize - n));
if (x == y)
{
if (asize != 0)
std::cout << "YES"
<< " 0." << x << "*10^" << asize;
else
std::cout << "YES"
<< " 0." << x;
}
else
{
std::cout << "NO";
if (asize != 0)
std::cout << " 0." << x << "*10^" << asize;
else
std::cout << " 0." << x;
if (bsize != 0)
std::cout << " 0." << y << "*10^" << bsize;
else
std::cout << " 0." << y;
}
return 0;
}