#P4850. Chewbacca and Number

Chewbacca and Number

Chewbaсca and Number

题面翻译

Luke Skywalker给了Chewbacca一个正整数xx ,但是Chewbacca决定把这个数改掉。他可以把整数xx 每个位置上的数tt 改成9t9-t 。 请你帮助Chewbacca来计算一下,如何把xx 改成一个最小的正整数,注意,不能出现首位为00 的情况。

输入范围

输入一个正整数x(1x1018)x(1\leq x\leq 10^{18}) ,表示初始的数。

输出范围

输出最小可以改变的数,注意不能出现首位为00 的情况。

感谢@馒头精 提供的翻译

题目描述

Luke Skywalker gave Chewbacca an integer number x x . Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit t t means replacing it with digit 9t 9-t .

Help Chewbacca to transform the initial number x x to the minimum possible positive number by inverting some (possibly, zero) digits. The decimal representation of the final number shouldn't start with a zero.

输入格式

The first line contains a single integer x x (1<=x<=1018) (1<=x<=10^{18}) — the number that Luke Skywalker gave to Chewbacca.

输出格式

Print the minimum possible positive number that Chewbacca can obtain after inverting some digits. The number shouldn't contain leading zeroes.

样例 #1

样例输入 #1

27

样例输出 #1

22

样例 #2

样例输入 #2

4545

样例输出 #2

4444