forked from imdhanish/HackerEarth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBig_P_and_Math.java
More file actions
31 lines (27 loc) · 1.09 KB
/
Big_P_and_Math.java
File metadata and controls
31 lines (27 loc) · 1.09 KB
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
import java.util.*;
/*
Big P is fairly good in mathematics.
His teacher has asked him to add two numbers.
Now , Big P has a problem that he sometimes writes a '6' as a '5' and vice versa.
Given two numbers, A and B, calculate the minimum and the maximum sum Big P could possibly get.
Input:
The first and only line of input contains positive integers A and B .
Output:
In single line of output, print two space separated integers, minimum and maximum sum Big P could get.
Constraints:
1<= A,B <= 1000000
SAMPLE INPUT
11 25
SAMPLE OUTPUT
36 37
URL: https://www.hackerearth.com/problem/algorithm/big-p-and-math-15/description/
*/
class Big_P_and_Math {
public static void main(String args[] ) throws Exception {
Scanner in = new Scanner(System.in);
Integer a = in.nextInt();
Integer b = in.nextInt();
System.out.print(Integer.parseInt(a.toString().replaceAll("6","5"))+ Integer.parseInt(b.toString().replaceAll("6","5")) + " ");
System.out.print(Integer.parseInt(a.toString().replaceAll("5","6")) + Integer.parseInt(b.toString().replaceAll("5","6")) + " ");
}
}