petice | 프로그래밍의 벗 PivotOJ
PivotOJ

petice

시간 제한: 1000ms메모리 제한: 128MB출처: CHC 2006 National Competition #1 - SeniorsBOJ 3165

문제

Write a program that, given integers N and K, finds the smallest integer greater than N whose decimal representation contains at least K occurrences of digit 5.

입력

The first and only line of input contains two integers N and K, 1 ≤ N ≤ 1015, 1 ≤ K ≤ 15

출력

The first and only line of output should contain a single integer – the smallest number from the task description. 

Note: use the 64-bit signed integer type (int64 in Pascal, long long in C/C++). 

예제

예제 1

입력
99 1
출력
105

예제 2

입력
595 2
출력
655

예제 3

입력
123456789012345 3
출력
123456789012355
코드를 제출하려면 로그인하세요.