[BOJ/C#] 2864 5와 6의 차이
Algorithm 2023. 1. 31. 13:55반응형
https://www.acmicpc.net/problem/2864
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
namespace BOJ
{
class Program
{
static void Main(string[] args)
{
StreamReader sr = new StreamReader(new BufferedStream(Console.OpenStandardInput()));
StreamWriter sw = new StreamWriter(new BufferedStream(Console.OpenStandardOutput()));
string[] ab = sr.ReadLine().Split();
char[] a = ab[0].ToCharArray();
char[] b = ab[1].ToCharArray();
int max = 0;
int min = 0;
for (int i = 0; i < a.Length; i++)
if (a[i] == '5') a[i] = '6';
for (int i = 0; i < b.Length; i++)
if (b[i] == '5') b[i] = '6';
max = int.Parse(new string(a)) + int.Parse(new string(b));
for (int i = 0; i < a.Length; i++)
if (a[i] == '6') a[i] = '5';
for (int i = 0; i < b.Length; i++)
if (b[i] == '6') b[i] = '5';
min = int.Parse(new string(a)) + int.Parse(new string(b));
sw.Write("{0} {1}", min, max);
sr.Close();
sw.Close();
}
}
}
반응형
'Algorithm' 카테고리의 다른 글
[BOJ/C#] 11945 뜨거운 붕어빵 (0) | 2023.02.02 |
---|---|
[BOJ/C#] 4796 캠핑 (0) | 2023.01.31 |
[BOJ/C#] 10162 전자레인지 (0) | 2023.01.31 |
[프로그래머스] 비밀지도 (0) | 2023.01.29 |
[BOJ/C#] 2163 초콜릿 자르기 (0) | 2023.01.29 |