시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 9 2 2 40.000%

문제

양의 정수 n이 주어졌을 때, n의 배수 중에서 그 수를 구성하고 있는 서로 다른 숫자의 개수가 가장 작은 수 m을 구하는 프로그램을 작성하시오. 예를 들어 1334를 구성하는 서로 다른 숫자는 1, 3, 4 이다.

입력

입력은 여러 개의 테스트 케이스로 이루어져 있고, 각 테스트 케이스는 n이 포함되어 있는 한 줄로 이루어져 있다. 테스트 케이스는 50개를 넘지 않고, n은 65536보다 작거나 같은 자연수이다. 입력의 마지막 줄에는 0이 하나 주어진다.

출력

각 테스트 케이스에 대해서, 문제의 설명에 나와있는 m을 출력한다. 만약, 가능한 m이 여러 가지인 경우에는 가장 작은 값을 출력한다.

예제 입력 1

7
15
16
101
0

예제 출력 1

7
555
16
1111
W3sicHJvYmxlbV9pZCI6Ijc3ODQiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMxMWNcdWI4NWMgXHViMmU0XHViOTc4IFx1YzIyYlx1Yzc5MCIsImRlc2NyaXB0aW9uIjoiPHA+XHVjNTkxXHVjNzU4IFx1YzgxNVx1YzIxOCBuXHVjNzc0IFx1YzhmY1x1YzViNFx1Yzg0Y1x1Yzc0NCBcdWI1NGMsIG5cdWM3NTggXHViYzMwXHVjMjE4IFx1YzkxMVx1YzVkMFx1YzExYyBcdWFkZjggXHVjMjE4XHViOTdjIFx1YWQ2Y1x1YzEzMVx1ZDU1OFx1YWNlMCBcdWM3ODhcdWIyOTQgXHVjMTFjXHViODVjIFx1YjJlNFx1Yjk3OCBcdWMyMmJcdWM3OTBcdWM3NTggXHVhYzFjXHVjMjE4XHVhYzAwIFx1YWMwMFx1YzdhNSBcdWM3OTFcdWM3NDAgXHVjMjE4IG1cdWM3NDQgXHVhZDZjXHVkNTU4XHViMjk0IFx1ZDUwNFx1Yjg1Y1x1YWRmOFx1YjdhOFx1Yzc0NCBcdWM3OTFcdWMxMzFcdWQ1NThcdWMyZG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