시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 135 82 80 64.516%

문제

양의 정수 B와 N이 주어졌을 때, B에 가장 가까운 AN의 정수 A를 찾는 프로그램을 작성하시오. AN은 B보다 작거나, 크거나, 같다.

입력

입력은 여러 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있고, B와 N이 주어진다. (1 ≤ B ≤ 1,000,000, 1 ≤ N ≤ 9) 입력의 마지막 줄에는 0이 2개 주어진다.

출력

각 테스트 케이스에 해당하는 A를 출력한다.

예제 입력 1

4 3
5 3
27 3
750 5
1000 5
2000 5
3000 5
1000000 5
0 0

예제 출력 1

1
2
3
4
4
4
5
16

힌트

W3sicHJvYmxlbV9pZCI6IjQ2MTkiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWI4ZThcdWQyYjgiLCJkZXNjcmlwdGlvbiI6IjxwPlxyXG5cdFx1YzU5MVx1Yzc1OCBcdWM4MTVcdWMyMTggQlx1YzY0MCBOXHVjNzc0IFx1YzhmY1x1YzViNFx1Yzg0Y1x1Yzc0NCBcdWI1NGMsIEJcdWM1ZDAgXHVhYzAwXHVjN2E1IFx1YWMwMFx1YWU0Y1x1YzZiNCBBPHN1cD5OPFwvc3VwPlx1Yzc1OCBcdWM4MTVcdWMyMTggQVx1Yjk3YyBcdWNjM2VcdWIyOTQgXHVkNTA0XHViODVjXHVhZGY4XHViN2E4XHVjNzQ0IFx1Yzc5MVx1YzEzMVx1ZDU1OFx1YzJkY1x1YzYyNC4gQTxzdXA+TjxcL3N1cD5cdWM3NDAgQlx1YmNmNFx1YjJlNCBcdWM3OTFcdWFjNzBcdWIwOTgsIFx1ZDA2Y1x1YWM3MFx1YjA5OCwgXHVhYzE5XHViMmU0LjxcL3A+XHJcbiIsImlucHV0IjoiPHA+XHJcblx0XHVjNzg1XHViODI1XHVjNzQwIFx1YzVlY1x1YjdlYyBcdWQxNGNcdWMyYTRcdWQyYjggXHVjZjAwXHVj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