[ Algorithm ]/[ PYTHON ]
BOJ_2864 [ 5와 6의 차이 ] [ 파이썬 ]
라이언
2020. 6. 1. 17:52
반응형
문제
https://www.acmicpc.net/problem/2864
2864번: 5와 6의 차이
문제 상근이는 2863번에서 표를 너무 열심히 돌린 나머지 5와 6을 헷갈리기 시작했다. 상근이가 숫자 5를 볼 때, 5로 볼 때도 있지만, 6으로 잘못 볼 수도 있고, 6을 볼 때는, 6으로 볼 때도 있지만, 5�
www.acmicpc.net
문제 해결 방법
내장함수 replace를 사용해서 최소값을 구할때는 6을 5로
최대값을 구할때는 5를 6으로 변경 후 더해서 출력하면 된다.
소스 코드 보기
https://github.com/jokerKwu/BOJ_Algorithm/blob/master/python/BOJ_2864.py
jokerKwu/BOJ_Algorithm
Contribute to jokerKwu/BOJ_Algorithm development by creating an account on GitHub.
github.com
import sys
input = sys.stdin.readline
a, b = map(str, input().split())
a = str(a).replace('6','5')
b = str(b).replace('6','5')
print(int(a)+int(b), end=' ')
a = str(a).replace('5','6')
b = str(b).replace('5','6')
print(int(a)+int(b), end=' ')
반응형