submission_id string | problem_id string | status string | code string | input string | output string | problem_description string |
|---|---|---|---|---|---|---|
s968504129 | p04045 | Wrong Answer | N, K = map(int, input().split())
L = sorted(set(map(str, range(10))) - set(input().split()))
import bisect
ans =''
i = 0
while i < len(str(N)):
x = str(N)[::-1][i]
if x in L:
ans += x
i = i + 1
continue
p = bisect.bisect_right(L, x)
if p < len(L):
ans += L[p]
else:
N += (10 + int(L[0]) - int(x)) * 10 ** i
ans += L[0]
i = i + 1
print(ans[::-1]) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s470389062 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = [Di for Di in input().split()]
for n in range(N, 10000):
n = str(n)
flag = True
for i in range(len(str(n))):
if n[i] in D:
flag = False
break
if flag:
print(n)
exit() | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s921251792 | p04045 | Wrong Answer | n,k = map(int,raw_input().split())
arr = [0,1,2,3,4,5,6,7,8,9]
r = map(int,raw_input().split())
for i in r:
arr.remove(i)
def count_digit(num):
count = 0
t = num
while t > 0 :
count += 1
t /= 10
return count
dc = count_digit(n)
ans = float("inf")
def dfs(s,i):
global ans,n,dc
if i == dc :
ret = int(s)
if ret >= n:
ans = min(ans,ret)
else :
for j in arr :
dfs(s + str(j),i + 1)
dfs('',0)
print ans
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s339605845 | p04045 | Wrong Answer | n,k = map(int,raw_input().split())
arr = [0,1,2,3,4,5,6,7,8,9]
r = map(int,raw_input().split())
for i in r:
arr.remove(i)
print arr
def count_digit(num):
count = 0
t = num
while t > 0 :
count += 1
t /= 10
return count
dc = count_digit(n)
ans = float("inf")
def dfs(s,i):
global ans,n,dc
if i == dc :
ret = int(s)
if ret >= n:
ans = min(ans,ret)
else :
for j in arr :
dfs(s + str(j),i + 1)
dfs('',0)
print ans
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s992615834 | p04045 | Wrong Answer | import itertools
str_n, str_k = input().split()
n = int(str_n)
k = int(str_k)
d = set([int(di) for di in input().split()])
opt = list({0,1,2,3,4,5,6,7,8,9} - d)
res = []
for opts in itertools.product(opt, repeat=len(str_n)+1):
r = 0
for i in range(0, len(str_n)+1):
r += opts[i] * 10**i
res.append(r)
for r in sorted(set(res)):
if r >= n:
print(r)
break | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s971965366 | p04045 | Wrong Answer | import itertools
str_n, str_k = input().split()
n = int(str_n)
k = int(str_k)
d = set([int(di) for di in input().split()])
opt = list({0,1,2,3,4,5,6,7,8,9} - d)
res = []
for opts in itertools.product(opt, repeat=len(str_n)):
r = 0
for i in range(0, len(str_n)):
r += opts[i] * 10**i
res.append(r)
for r in sorted(set(res)):
if r >= n:
print(r)
break | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s021505146 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = list(map(int, input().split()))
N_str = str(N)
N_str_rv = list(N_str)[::-1]
i = 0
ans = []
while i<len(N_str_rv):
flag = 1
for num in range(int(N_str_rv[i]),10):
if not num in D:
ans.append(num)
N += (num-int(N_str_rv[i]))*(10**i)
N_str_rv = list(str(N))[::-1]
#N_str_rv[i] = str(num)
i+=1
flag = 0
break
if flag:
N += (10-int(N_str_rv[i]))*(10**i)
N = N - N%(10**i)
ans = []
i = 0
N_str_rv = list(str(N))[::-1]
answer = 0
for i,num in enumerate(ans):
answer += num*(10**i)
print(answer) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s816278138 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = list(map(int, input().split()))
N_str = str(N)
N_str_rv = list(N_str)[::-1]
i = 0
ans = []
while i<len(N_str_rv):
flag = 1
for num in range(int(N_str_rv[i]),10):
if not num in D:
ans.append(num)
N += (num-int(N_str_rv[i]))*(10**i)
N_str_rv = list(str(N))[::-1]
#N_str_rv[i] = str(num)
i+=1
flag = 0
break
if flag:
N += (10-int(N_str_rv[i]))*(10**i)
N = int(round(N,-i))
ans = []
i = 0
N_str_rv = list(str(N))[::-1]
answer = 0
for i,num in enumerate(ans):
answer += num*(10**i)
print(answer) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s774682577 | p04045 | Wrong Answer | import itertools, math
n, k = map(int, input().split())
nums = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} - {x for x in input().split()}
ans = float("inf")
for cnt in range(10001):
tmp = set(list(str(cnt)))
if tmp <= nums and n <= cnt < ans:
ans = cnt
print(ans)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s141536893 | p04045 | Wrong Answer | import itertools, math
n, k = map(int, input().split())
nums = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} - {x for x in input().split()}
ans = float("inf")
for cnt in range(10001):
tmp = set(list(str(cnt)))
print(tmp, cnt)
if tmp <= nums and n <= cnt < ans:
ans = cnt
print(ans)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s685098438 | p04045 | Wrong Answer | import itertools, copy
n, k = map(int, input().split())
array = set([int(x) for x in input().split()])
res = map(str, {1, 2, 3, 4, 5, 6, 7, 8, 9, 0} - array)
res2 = list(res)
array = itertools.product(res, repeat=len(str(n))+1)
ans = float("inf")
for i in array:
tmp = int("".join(i))
if n <= tmp < ans:
ans = tmp
array = itertools.product(res2, repeat=len(str(n)))
for i in array:
tmp = int("".join(i))
if n <= tmp < ans:
ans = tmp
print(ans) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s305450552 | p04045 | Wrong Answer | import itertools
n, k = map(int, input().split())
array = set([int(x) for x in input().split()])
res = map(str, set([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) - array)
array = itertools.product(res, repeat=len(str(n))+1)
ans = float("inf")
for i in array:
tmp = int("".join(i))
if n <= tmp < ans:
ans = tmp
print(ans) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s333956812 | p04045 | Wrong Answer | import itertools
n, k = map(int, input().split())
array = set([int(x) for x in input().split()])
res = map(str, set([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) - array)
array = itertools.product(res, repeat=len(str(n)))
ans = float("inf")
for i in array:
tmp = int("".join(i))
if n <= tmp < ans:
ans = tmp
print(ans) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s309921845 | p04045 | Wrong Answer | n,k=map(int,input().split())
d=list(map(int,input().split()))
a=[0,1,2,3,4,5,6,7,8,9]
for i in d:
del a[a.index(i)]
for i in a:
for j in a:
for k in a:
for l in a:
for m in a:
p=int(i*10**4+j*10**3+k*10**2+l*10+m)
if p>=n:
break
break
break
break
break
print(p) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s712282616 | p04045 | Wrong Answer | n, k = list(map(int, input().split()))
d = list(map(int, input().split()))
n = str(n)
ans = ''
for i, nn in enumerate(n):
while(True):
if int(nn) in d:
nn = str(int(nn)+1)
else:
ans += nn
break
print(ans)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s376078177 | p04045 | Wrong Answer | n,k = map(int, input().split())
d = list(map(int, input().split()))
a = []
for i in range(10):
if not i in d:
a.append(str(i))
for i in range(n, 10000):
tmp = str(i)
ok = 0
for j in tmp:
if j in a:
ok += 1
if ok == len(tmp):
break
print(int(tmp))
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s804339099 | p04045 | Wrong Answer | n, k = map(int, raw_input().split())
d = map(int, raw_input().split())
res = ''
while n > 0:
b = n % 10
n = n / 10
plus = False
while b in d:
b += 1
if b == 10:
plus = True
b = 0
res = str(b) + res
if plus:
n += 1
print(res)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s252789660 | p04045 | Wrong Answer | N,K = map(int,input().split( ))
Ds = list(map(int,input().split( )))
word = list(map(int,list(str(N))))
z = 0
while z in Ds:
z += 1
for i in range(len(word)):
for j in range(len(Ds)):
if word[-i-1] in Ds:
word[-i-1] += 1
if i > 0:
word[-i:] = [z for i in range(i)]
if word[-i-1]>=10:
if i == len(word)-1:
word.insert(0,0)
word[-i-2] += 1
word[-i-1:] += [z for i in range(i+1)]
s = list(map(str,word))
print(''.join(s)) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s270327943 | p04045 | Wrong Answer | n, k = map(int,input().split())
unlike = list(map(int,input().split()))
like = [0]
for i in range(1, 10):
if i not in unlike:
like.append(i)
def func(arr):
return list(map(int,list(str(arr))))
for i in range(n,80001):
ans = func(i)
if not(set(ans) - set(like)):
print(''.join(map(str,ans)))
break | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s601274318 | p04045 | Wrong Answer | n, k = map(int,input().split())
unlike = list(map(int,input().split()))
like = [0]
flg = False
for i in range(1, 10):
if i not in unlike:
like.append(i)
def func(arr):
return list(map(int,list(str(arr))))
for i in range(n,10000):
ans = func(i)
if not(set(ans) - set(like)):
print(''.join(map(str,ans)))
break | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s732345139 | p04045 | Wrong Answer | import itertools
n, k = map(int,input().split())
unlike = list(map(int,input().split()))
like = [0]
ans = []
def _join(arr):
num = 0
for i in range(len(str(n))):
num += arr[i] * (10 ** (len(arr) - i - 1))
return num
for i in range(1, 10):
if i not in unlike:
like.append(i)
def rev(arr):
arr.reverse()
return arr
arr = list(itertools.combinations_with_replacement(like,len(str(n))))
for i in arr:
ans.append(_join(i))
a = rev(list(i))
ans.append(_join(a))
for i in ans:
if n <= i:
print(i)
break | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s455103431 | p04045 | Wrong Answer | n,k=map(int, input().split())
d=list(input().split())
ans=10000
for i in range(n,10000):
for j in d:
if str(i).count(j):break
else:
ans=i
break
print(ans) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s414616625 | p04045 | Wrong Answer | n,k=map(int, input().split())
d=list(input().split())
ans=10000
for i in range(n,10000):
for j in d:
if str(i).count(j):break
else:
ans=min(ans,i)
break
print(ans) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s236547223 | p04045 | Wrong Answer | n,k=map(int, input().split())
d=list(map(int, input().split()))
ans=10000
for i in range(n,10001):
for j in d:
if str(i).count(str(j)):break
else:
ans=min(ans,i)
print(ans) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s837771226 | p04045 | Wrong Answer | n, k = [i for i in input().split()]
d = [i for i in input().split()]
# OK 숫자의 집합을 구하고,
# 각 자리수부터 들어가 NG 숫자를 OK숫자로 바꿔주면 되는 거 아냐?
n = list(n)
ng = set(d)
for i in range(len(n)):
# print(ng)
ok = set([str(i) for i in range(10)]) - ng
# print(ok)
if i == 0 and '0' in ok:
ok.remove('0')
ng.add('0')
if n[i] in ng:
n[i] = str(min(ok))
print(''.join(n)) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s379883206 | p04045 | Wrong Answer | n, k = [i for i in input().split()]
d = [i for i in input().split()]
# OK 숫자의 집합을 구하고,
# 각 자리수부터 들어가 NG 숫자를 OK숫자로 바꿔주면 되는 거 아냐?
n = list(n)
ng = set(d)
for i in range(len(n)):
# print(ng)
ok = set([str(i) for i in range(10)]) - ng
# print(ok)
if i == 0 and '0' in ok:
ok.remove('0')
if n[i] in ng:
n[i] = str(min(ok))
print(''.join(n)) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s925440318 | p04045 | Wrong Answer | n, k = map(int, input().split())
d = list(map(int, input().split()))
for i in range(10*n+2):
if i >= n:
s = str(i)
for j in range(len(s)):
if int(s[j]) in d:
break
else:
print(i)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s773042031 | p04045 | Wrong Answer | n, k = map(int, input().split())
d = list(map(int, input().split()))
for i in range(10*n+2):
if i >= n:
s = str(i)
for j in range(len(s)):
if int(s[j]) in d:
break
print(i)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s430059534 | p04045 | Wrong Answer | n, k = map(int, input().split())
d = list(map(int, input().split()))
for i in range(10*n+2):
if i >= n:
s = str(i)
for j in range(len(s)):
if int(s[j]) in d:
break
else:
print(i)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s419750555 | p04045 | Wrong Answer | n, k = map(int, input().split())
d_list = list(map(int, input().split()))
num_list = [0,1,2,3,4,5,6,7,8,9]
for d in d_list:
num_list.remove(d)
final_price = ''
def is_dislike_number(number, dislike_list):
if number in dislike_list:
return True
else:
return False
for i, num in enumerate(str(n)):
num = int(num)
if is_dislike_number(num, d_list):
while num < 10:
num += 1
if num == 10:
num = num_list[0] * 10
digit = len(str(n)) - i - 1
if not is_dislike_number(num, d_list):
final_price += str(num)
for j in range(digit):
final_price += str(num_list[0])
print(final_price)
exit()
final_price += str(num)
print(final_price)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s445476428 | p04045 | Wrong Answer | n, k = map(int, input().split())
d_list = list(map(int, input().split()))
num_list = [0,1,2,3,4,5,6,7,8,9]
for d in d_list:
num_list.remove(d)
final_price = ''
def is_dislike_number(number, dislike_list):
if number in dislike_list:
return True
else:
return False
for i, num in enumerate(str(n)):
num = int(num)
if is_dislike_number(num, d_list):
while num < 10:
num += 1
digit = len(str(n)) - i - 1
if not is_dislike_number(num, d_list):
final_price += str(num)
for j in range(digit):
final_price += str(num_list[0])
print(final_price)
exit()
final_price += str(num)
print(final_price)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s181941046 | p04045 | Wrong Answer | n, k = map(int, input().split())
d_list = list(map(int, input().split()))
num_list = [0,1,2,3,4,5,6,7,8,9]
for d in d_list:
num_list.remove(d)
final_price = ''
def is_dislike_number(number, dislike_list):
if number in dislike_list:
return True
else:
return False
for i, num in enumerate(str(n)):
num = int(num)
if is_dislike_number(num, d_list):
while num < 10:
num += 1
digit = len(str(n)) - i - 1
if not is_dislike_number(str(num), d_list):
final_price += str(num)
for j in range(digit):
final_price += str(num_list[0])
print(final_price)
exit()
final_price += str(num)
print(final_price)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s179027204 | p04045 | Wrong Answer | n,m = map(int,input().split())
num_list = list(map(int,input().split()))
while(True):
flag=True;
num=n
while(num!=0):
for i in num_list:
if(num//10 == i):
flag=False
num = num/10
if(flag==True):
print(n)
break
else :
n=n+1
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s279166392 | p04045 | Wrong Answer | N,K = map(int, input().split())
D = input().split()
ans = N
while True:
ch_n = str(ans)
for c in ch_n:
if c in D:
break
print(ans)
exit()
ans += 1
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s988114629 | p04045 | Wrong Answer | N,K = map(int, input().split())
D = list(map(int, input().split()))
while True:
ch_n = str(N)
for c in ch_n:
if int(c) in D:
break
print(N)
exit()
N += 1
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s794339751 | p04045 | Wrong Answer | N,K = (int(i) for i in input().split())
D = [int(i) for i in input().split()]
n = len(str(N))
for i in range(1,10):
if i not in D:
print(str(i)*(n+1)) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s152783021 | p04045 | Wrong Answer | n,k = map(int, input().split())
d = list(map(int, input().split()))
check = [False]*10
for i in range(k):
check[d[i]] = True
def judge(x):
while x > 0:
if check[x%10]:
return False
x //= 10
return True
if judge(n):
ans = n
else:
min_allow = 0
for i in range(10):
if not check[i]:
min_allow = i
break
ans = 0
l = len(str(n))-1
top = n//(10**l)
for i in range(top, top+10):
if i%10 == 0:
continue
if not check[i%10]:
if i > 10:
l += 1
ans = (i%10)*10**l
break
for i in range(l):
ans += min_allow*10**i
print(ans)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s087946204 | p04045 | Wrong Answer | n,k = map(int, input().split())
d = list(map(int, input().split()))
check = [False]*10
for i in range(k):
check[d[i]] = True
def judge(x):
while x > 0:
if check[x%10]:
return False
x //= 10
return True
if judge(n):
ans = n
else:
min_allow = 0
for i in range(10):
if not check[i]:
min_allow = i
break
ans = 0
l = len(str(n))-1
top = n%(10**l)
new_top = 0
for i in range(top, top+10):
if i%10 == 0:
continue
if not check[i%10]:
if i > 10:
l += 1
ans = (i%10)*10**l
break
for i in range(l):
ans += min_allow*10**i
print(ans)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s778616021 | p04045 | Wrong Answer | N, K = map(int, input().split())
a = set(range(10))
d = set([int(i) for i in input().split()])
b = a - d
k = {}
c = 0
n = N
while n:
n, r = divmod(n, 10)
k[c] = r
c += 1
ans = 0
l = len(k.keys())
for i, j in enumerate(sorted(k.keys())):
if j != (l-1) and not k[j] in b:
ans += 10**j * min(b)
elif j == (l-1) and not k[j] in b:
if k[j] > max(b):
ans += 10**(j+1) * min(b-{0}) + 10**(j) *min(b)
else:
for a in sorted(list(b)):
if k[j] < a:break
ans += 10**j * a
else:
ans += 10**j * k[j]
print(ans) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s074254397 | p04045 | Wrong Answer | N, K = map(int, input().split())
a = set(range(10))
d = set([int(i) for i in input().split()])
b = a - d
k = {}
c = 0
n = N
while n:
n, r = divmod(n, 10)
k[c] = r
c += 1
ans = 0
l = len(k.keys())
for i, j in enumerate(sorted(k.keys())):
if j != (l-1) and not k[j] in b:
ans += 10**j * min(b)
elif j == (l-1) and not k[j] in b:
if k[j] > max(b):
ans += 10**(j+1) * min(b-{0}) + 10**(j) *min(b-{0})
else:
for a in sorted(list(b)):
if k[j] < a:break
ans += 10**j * a
else:
ans += 10**j * k[j]
print(ans)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s633148507 | p04045 | Wrong Answer | N, K = map(int, input().split())
a = set(range(10))
d = set([int(i) for i in input().split()])
b = a - d
k = {}
c = 0
n = N
while n:
n, r = divmod(n, 10)
k[c] = r
c += 1
ans = 0
l = len(k.keys())
for i, j in enumerate(sorted(k.keys())):
if j != (l-1) and not k[j] in b:
ans += 10**j * min(b)
elif j == (l-1) and not k[j] in b:
if k[j] > max(b):
ans += 10**(j+1) * min(b) + 10**(j) *min(b)
else:
for a in sorted(list(b)):
if k[j] < a:break
ans += 10**j * a
else:
ans += 10**j * k[j]
print(ans)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s253207392 | p04045 | Wrong Answer | N, K = map(int, input().split())
a = set(range(10))
d = set([int(i) for i in input().split()])
b = a - d
k = {}
c = 0
n = N
while n:
n, r = divmod(n, 10)
k[c] = r
c += 1
ans = 0
l = len(k.keys())
for i, j in enumerate(sorted(k.keys())):
if j != (l-1) and not k[j] in b:
ans += 10**j * min(b)
elif j == (l-1) and not k[j] in b:
if k[j] > max(b):
ans += 10**(j+1) * min(b)
else:
for a in sorted(list(b)):
if k[j] < a:break
ans += 10**j * a
else:
ans += 10**j * k[j]
print(ans) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s037251728 | p04045 | Wrong Answer | n, k = map(int, input().split())
d = list(input().split())
num = n
found = False
while not found:
for e in d:
if e in set(str(num)):
num += 1
break
found = True
print(num) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s422379422 | p04045 | Wrong Answer | n, k = map(int, input().split())
d = list(map(int, input().split()))
num = n
found = False
while not found:
for i in list(str(num)):
for d_k in d:
if i == d_k:
num += 1
break
found = True
print(num)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s701069037 | p04045 | Wrong Answer | def main():
n, k = map(int, input().split())
d = set(map(int, input().split()))
c = list(set(range(10)).difference(d))
c.sort()
num, success = sup(n, c)
if success:
ans = num
else:
c_min = c[0]
ans = c_min*10000 + c_min*1000 + c_min*100 + c_min*10 + c_min
print(ans)
def sup(n, c):
for i1 in c:
for i2 in c:
for i3 in c:
for i4 in c:
num = i1*1000 + i2*100 + i3*10 + i4
if n <= num:
return num, True
return None, False
if __name__ == '__main__':
main()
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s061294020 | p04045 | Wrong Answer | def find_next_valid_digit(d, bad_nums):
next_digit = d
while True:
next_digit = next_digit + 1
valid = True
for c in str(next_digit):
if int(c) in bad_nums:
valid = False
break
if valid:
break
return next_digit
if __name__ == '__main__':
n, k = list(map(int, input().split(' ')))
bad_nums = list(map(int, input().split(' ')))
n_str = str(n)
cur_result = 0
for i in range(len(n_str)):
most_significant_digit = int(n_str[i])
if most_significant_digit in bad_nums:
basis = cur_result * 10 + most_significant_digit
cur_result = find_next_valid_digit(basis, bad_nums)
cur_result = cur_result * (10 ** (len(n_str) - i - 1))
break
else:
cur_result = cur_result * 10 + most_significant_digit
print(cur_result) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s691406476 | p04045 | Wrong Answer | n, k = (int(i) for i in input().split())
number = [int(i) for i in input().split()]
answer = 0
list_n = str(n)
count = list(map(int, list_n))
def check(true_number, answer):
answer = str(answer)
for i in true_number:
if str(i) in answer:
break
else:
return False
return True
true_number = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in number:
if i in true_number:
true_number.remove(i)
answer = n
while 1:
if check(true_number, answer):
break
else:
answer += 1
print(answer) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s920870425 | p04045 | Wrong Answer | n, k = (int(i) for i in input().split())
number = [int(i) for i in input().split()]
answer = []
list_n = str(n)
count = list(map(int, list_n))
true_number = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in number:
if i in true_number:
true_number.remove(i)
flag = 0
for j in count:
for i in true_number:
if j < i:
answer.append(i)
flag=1
break
elif flag == 1 and true_number.count(0) == 1:
answer.append(0)
break
elif j == i:
answer.append(i)
flag =0
break
print(''.join(map(str, answer))) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s412913133 | p04045 | Wrong Answer | n, k = (int(i) for i in input().split())
number = [int(i) for i in input().split()]
answer = []
list_n = str(n)
count = list(map(int, list_n))
true_number = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in number:
if i in true_number:
true_number.remove(i)
flag = 0
for j in count:
for i in true_number:
if j < i:
answer.append(i)
flag=1
break
elif flag == 1 and true_number.count(0):
answer.append(0)
break
elif j == i:
answer.append(i)
flag =0
print(''.join(map(str, answer))) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s798457901 | p04045 | Wrong Answer | n, k = (int(i) for i in input().split())
number = [int(i) for i in input().split()]
answer = []
list_n = str(n)
count = list(map(int, list_n))
true_number = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in number:
if i in true_number:
true_number.remove(i)
for j in count:
for i in true_number:
if j <= i:
answer.append(i)
break
print(''.join(map(str, answer))) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s408556039 | p04045 | Wrong Answer | import math
l = list(map(int,input().split()))
n = l[0]
k = l[1]
d = list(map(int,input().split()))
hoge = list(range(10))
for i in d:
hoge.remove(i)
dig = math.ceil(math.log(n,10))
po = 0
for i in range(dig):
po += hoge[len(hoge)-1]*(10**i)
ans = 0
if po < n:
if 0 in hoge:
print(hoge[1]*(10**dig))
else:
for i in range(dig+1):
ans += ans*10+hoge[0]
print(ans)
else:
for i in range(dig):
r = n%10
for j in hoge:
if r <= j:
ans+=j*(10**i)
break
n=math.floor(n/10)
print(ans) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s245034338 | p04045 | Wrong Answer | def main():
N, K = map(int, input().split())
D = set(map(int, input().split()))
for i in range(10):
if i not in D:
min_ = i
break
k = 10 ** (len(str(N)) - 1)
ans = []
apnd = ans.append
num, flag = N, 0
while k > 0:
if not flag:
while num // k in D:
num += k
if num // k > 9:
k *= 10
flag = 1
d, num = divmod(num, k)
apnd(d)
else:
apnd(min_)
k //= 10
print(*ans, sep='')
main()
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s950307528 | p04045 | Wrong Answer | def main():
N, K = map(int, input().split())
D = set(map(int, input().split()))
ans = []
apnd = ans.append
num = N
while num > 0:
while num % 10 in D:
num += 1
num, m = divmod(num, 10)
apnd(m)
print(*ans[::-1], sep='')
main()
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s727309719 | p04045 | Wrong Answer | def main():
N, K = map(int, input().split())
D = set(map(int, input().split()))
k = len(str(N))
ans = [0] * k
num = N
for i in range(1, k + 1):
while num % 10 in D:
num += 1
num, ans[k-i] = divmod(num, 10)
print(*ans, sep='')
main()
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s346489713 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = list(map(int, input().split()))
shiharai = N
l = [int(x) for x in list(str(N))]
c = len(l)
for i in range(len(l)):
while l[i] in D:
shiharai+=1
l = [int(x) for x in list(str(shiharai))]
if len(l)==c+1:
while l[c] in D:
shiharai+=1
l = [int(x) for x in list(str(shiharai))]
print(shiharai) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s809659370 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = list(map(int, input().split()))
shiharai=N
l = [int(x) for x in list(str(N))]
c=len(l)
for i in range(len(l)):
while l[i] in D:
shiharai+=1
l = [int(x) for x in list(str(shiharai))]
if len(l)!=c:
for i in range(len(l)):
while l[i] in D:
shiharai+=1
l = [int(x) for x in list(str(shiharai))]
print(shiharai) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s414265407 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = list(map(int, input().split()))
shiharai=N
l = [int(x) for x in list(str(N))]
c=len(l)
for i in range(len(l)):
while l[i] in D:
shiharai+=1
l = [int(x) for x in list(str(shiharai))]
if len(l)!=c:
while l[len(l)-1] in D:
shiharai+=1
l = [int(x) for x in list(str(shiharai))]
print(shiharai) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s600202062 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = list(map(int, input().split()))
shiharai=N
l = [int(x) for x in list(str(N))]
c=len(l)
for i in range(len(l)):
while l[i] in D:
shiharai+=1
l = [int(x) for x in list(str(shiharai))]
if len(l)!=c:
while l[len(l)-1] in D:
shiharai+=1
l = [int(x) for x in list(str(shiharai))]
print(shiharai) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s065054745 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = list(map(int, input().split()))
shiharai=N
l = [int(x) for x in list(str(N))]
c=len(l)
for i in range(len(l)):
while l[i] in D:
shiharai+=1
l = [int(x) for x in list(str(shiharai))]
if len(l)!=c:
while l[len(l)-1] in D:
shiharai+=1 | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s541966423 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = list(map(int, input().split()))
shiharai=N
l = [int(x) for x in list(str(N))]
for i in range(len(l)):
while l[i] in D:
shiharai+=1
l = [int(x) for x in list(str(shiharai))]
print(shiharai) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s103039320 | p04045 | Wrong Answer | n, k = input().split()
o = map(int, input().split())
nums = map(int, list(n))
l = []
for v in nums:
while v in o:
v += 1
l.append(v)
print(''.join(map(str, l)))
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s195961352 | p04045 | Wrong Answer | # -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem C
if __name__ == '__main__':
n, k = list(map(str, input().split()))
d = list(map(str, input().split()))
numbers = [str(i) for i in range(0, 10)]
like_numbers = set(numbers) - set(d)
for i in like_numbers:
for j in like_numbers:
for k in like_numbers:
for l in like_numbers:
number_candidate = i + j + k + l
if number_candidate >= n:
print(number_candidate)
exit()
print(int(n) + 1)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s608475586 | p04045 | Wrong Answer | # -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem C
if __name__ == '__main__':
n, k = list(map(str, input().split()))
d = list(map(str, input().split()))
numbers = [str(i) for i in range(0, 10)]
like_numbers = set(numbers) - set(d)
for i in like_numbers:
for j in like_numbers:
for k in like_numbers:
for l in like_numbers:
number_candidate = i + j + k + l
if number_candidate >= n:
print(number_candidate)
exit()
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s328823200 | p04045 | Wrong Answer | n, k = list(map(int, input().split()))
d = list(map(int, input().split()))
if 0 in d:
zero = True
else:
zero = False
n_ok = {0} | set([0,1,2,3,4,5,6,7,8,9]) - set(d)
n_oks = sorted(n_ok)
#print(n_oks)
def lowest():
for i in n_oks:
for j in n_oks:
for k in n_oks:
for l in n_oks:
for m in n_oks:
money = 10000*i +1000*j + 100*k + 10*l + m
if money >= n:
if zero and 0 in [i,j,k,l,m]:
if i != 0:
continue
if 0 in [j,k,l,m] and j != 0:
continue
if 0 in [k,l,m] and k != 0:
continue
if 0 in [l,m] and l != 0:
continue
print(money)
return 0
lowest() | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s954202219 | p04045 | Wrong Answer | N,K=map(int,input().split())
D=[int(i) for i in input().split()]
T=[0 for i in range(10)]
for i in D:
T[i]=1
S=[]
for i in range(10):
if T[i]==0:
S.append(i)
import itertools
L=list(itertools.product(S,S,S,S))
R=sorted([int(str(i[0])+str(i[1])+str(i[2])+str(i[3])) for i in L])
for i in R:
if i>=N:
print(i)
exit()
if S[0]!=0:
print(str(S[0])*5)
else:
print(str(S[1])+"0000")
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s866442311 | p04045 | Wrong Answer | N,K=map(int,input().split())
D=[int(i) for i in input().split()]
T=[0 for i in range(10)]
for i in D:
T[i]=1
S=[]
for i in range(10):
if T[i]==0:
S.append(i)
import itertools
L=list(itertools.product(S,S,S,S))
R=sorted([int(str(i[0])+str(i[1])+str(i[2])+str(i[3])) for i in L])
for i in R:
if i>=N:
print(i)
exit()
print(str(min(S))*5)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s628515290 | p04045 | Wrong Answer | N,K=map(int,input().split())
D=[int(i) for i in input().split()]
T=[0 for i in range(10)]
for i in D:
T[i]=1
S=[]
for i in range(10):
if T[i]==0:
S.append(i)
import itertools
L=list(itertools.product(S,S,S,S))
R=sorted([int(str(i[0])+str(i[1])+str(i[2])+str(i[3])) for i in L])
for i in R:
if i>=N:
print(i)
exit()
print(min(S)*5)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s253102326 | p04045 | Wrong Answer | N,K=map(int,input().split())
D=[int(i) for i in input().split()]
T=[0 for i in range(10)]
for i in D:
T[i]=1
S=[]
for i in range(10):
if T[i]==0:
S.append(i)
import itertools
L=list(itertools.product(S,S,S,S))
R=[int(str(i[0])+str(i[1])+str(i[2])+str(i[3])) for i in L]
for i in R:
if i>=N:
print(i)
exit()
print(min(S)*5)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s087985534 | p04045 | Wrong Answer | N, K = map(int, input().split())
a = input().split()
for i in range(N-1, N*100):
for j in str(i):
if j in a:
break
else:
print(i)
break | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s835568973 | p04045 | Wrong Answer | n,k = (int(i) for i in input().split())
d = [int(i) for i in input().split()]
for i in range(n,10000):
a = str(i)
if all(int(j) not in d for j in a):
print(i)
break | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s439874363 | p04045 | Wrong Answer | from functools import reduce
def obsession(n, disliked):
def nearest(digit):
for i in range(digit, digit + 10):
mod10 = i % 10
if mod10 not in disliked:
return (mod10, i != mod10)
will_pay = list(map(int, str(n)))
index = 0
while index < len(will_pay):
digit = will_pay[index]
if digit in disliked:
substitute, carry = nearest(digit)
will_pay[index] = substitute
while carry and index > 0:
substitute, carry = nearest(will_pay[index - 1] + 1)
will_pay[index - 1] = substitute
index -= 1
if carry:
will_pay.insert(0, nearest(1)[0])
index += 1
index += 1
return reduce(lambda x, y: x * 10 + y, will_pay, 0)
if __name__ == '__main__':
n, _ = map(int, input().split())
disliked = set(map(int, input().split()))
print(obsession(n, disliked)) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s233853765 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = input().split()
for i in range(N, 10001):
string = set(list(str(i)))
for s in string:
if s in D:
break
else:
print(i)
break
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s076697782 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = set(input().split())
for i in range(N, 10001):
string = set(list(str(i)))
for s in string:
if s in D:
break
else:
print(i)
break
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s608346041 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = set(input().split())
for i in range(N, 10001):
string = set(str(i))
for s in string:
if s in D:
break
else:
print(i)
break
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s509466488 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = set(input().split())
array = set(str(i) for i in range(10)) - D
for i in range(N, 10001):
string = set(str(i))
for s in string:
if s in array:
continue
break
else:
print(i)
break
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s527119790 | p04045 | Wrong Answer | n,k = map(int,input().split())
d = set(map(int,input().split()))
x = len(str(n))
for i in range(x):
while (n//(10**i))%10 in d:
n += 10**i
urad = {1,2,3,4,5,6,7,8,9} - d
if len(str(n)) != x and 1 in d:
n += (min(urad)-1)*(10**x)
print(n) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s835981545 | p04045 | Wrong Answer | n,k = map(int,input().split())
d = set(map(int,input().split()))
x = len(str(n))
for i in range(x):
while (n//(10**i))%(10**(i+1)) in d:
n += 10**i
urad = {1,2,3,4,5,6,7,8,9} - d
if len(str(n)) != x and 1 in d:
n += (min(urad)-1)*(10**x)
print(n)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s271085634 | p04045 | Wrong Answer | n,k = map(int,input().split())
d = set(map(int,input().split()))
x = len(str(n))
for i in range(x):
while (n//(10**i))%(10**(i+1)) in d:
n += 10**i
urad = {1,2,3,4,5,6,7,8,9} - d
if len(str(n)) != x :
n += (min(urad)-1)*(10**x)
print(n)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s809412848 | p04045 | Wrong Answer | n,k = map(int,input().split())
d = set(map(int,input().split()))
x = len(str(n))
for i in range(x):
while (n//(10**i))%(10**(i+1)) in d:
n += 10**i
urad = {1,2,3,4,5,6,7,8,9} - d
if len(str(n)) != x and 1 in d:
n += (min(d)-1)*(10**x)
print(n)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s043143616 | p04045 | Wrong Answer | n,k = map(int,input().split())
d = set(map(int,input().split()))
x = len(str(n))
for i in range(x):
while (n//(10**i))%(10**(i+1)) in d:
n += 10**i
urad = {1,2,3,4,5,6,7,8,9} - d
if len(str(n)) != x and 1 in d:
n += min(d)*(10**x)
print(n)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s412947138 | p04045 | Wrong Answer | n,k = map(int,input().split())
d = set(map(int,input().split()))
x = len(str(n))
for i in range(x):
while (n//(10**i))%(10**(i+1)) in d:
n += 10**i
urad = {1,2,3,4,5,6,7,8,9} - d
if 1 in d:
n += min(d)*(10**x)
print(n) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s387136463 | p04045 | Wrong Answer | import itertools
N, K = [int(s) for s in input().split()]
D = [int(s) for s in input().split()]
U = [str(n) for n in range(10) if n not in D]
ret = N * 10
for v in [int(''.join(T)) for T in itertools.product(U, repeat=4)]:
if N <= v:
ret = min(ret, v)
print(ret)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s069613034 | p04045 | Wrong Answer | import itertools
N, K = [int(s) for s in input().split()]
D = [int(s) for s in input().split()]
U = [str(n) for n in range(10) if n not in D]
ret = N * 10
for v in [int(''.join(T)) for T in itertools.product(U, repeat=4)]:
print(v)
if N <= v:
ret = min(ret, v)
print(ret)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s325294702 | p04045 | Wrong Answer | def c_IrohaObsession(N, K, D):
d = [str(i) for i in D]
i = N
while True:
for c in str(i):
if c in d:
break
else:
return i
i += 1 | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s901070691 | p04045 | Wrong Answer | def c_IrohaObsession(N, K, D):
d = [str(i) for i in D]
for i in range(N, 10000):
for c in str(i):
if c in d:
break
else:
break
return i
N,K = [int(i) for i in input().split()]
D = [int(i) for i in input().split()]
print(c_IrohaObsession(N, K, D)) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s007707784 | p04045 | Wrong Answer | (n, k), d = map(int, raw_input().split()), set(raw_input().split())
for _ in xrange(n, 10000):
if not set(str(_)) & d:
print _
break
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s622547926 | p04045 | Wrong Answer | n, k = map(int, input().split())
num = input().split()
for i in range(n, 10000):
flug = True
istr = str(i)
for j in range(len(istr)):
if istr[j] in num:
flug = False
break
else:
pass
if flug:
print(i)
break
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s455392203 | p04045 | Wrong Answer | n=int(input().split()[0])
d=input()
k=1
while k <= n:
if str((n//k)%10) in d:
n+=k
else:
k*=10
print(n) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s833185367 | p04045 | Wrong Answer | N,K=map(int,raw_input().split())
D=map(int,raw_input().split())
n=[0,1,2,3,4,5,6,7,8,9]
a=[] #Allowed numbers
for i in n:
if i not in D:
a.append(i)
for i in range(N,10000):
for j in D:
if str(i).find(str(j))!=-1:
break
else:
print str(i)
break
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s330263505 | p04045 | Wrong Answer | N,K=map(int,raw_input().split())
D=map(int,raw_input().split())
n=[0,1,2,3,4,5,6,7,8,9]
a=[] #Allowed numbers
for i in n:
if i not in D:
a.append(i)
for i in range(N,10001):
for j in D:
if str(i).find(str(j))!=-1:
break
else:
print str(i)
break
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s080903163 | p04045 | Wrong Answer | n, k = list(map(int, input().split(" ")))
d = list(map(int, input().split(" ")))
t = 1
while n >= t:
digit = int((n / t) % 10)
if digit not in d:
t *= 10
continue
while digit in d:
n += t
digit = int((n / t) % 10)
t *= 10
print(n)
| 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s455430986 | p04045 | Wrong Answer | N, K = [int(n) for n in input().split()]
D = set([int(n) for n in input().split()])
def digits(n):
res = set()
while n > 0:
res = res.union(set([n%10]))
n //= 10
return res
n = 1
while True:
if digits(N*n).isdisjoint(D):
print(N*n)
break
n+=1 | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s111397550 | p04045 | Wrong Answer | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""042-c"""
import sys
def solve(dislike_digits_table, first_like_digit, N):
"""Solve."""
for i, c in enumerate(N):
while dislike_digits_table[int(c)]:
if c == '9':
if i == 0:
return solve(dislike_digits_table,
first_like_digit,
'1' + '0' * len(N))
else:
return solve(dislike_digits_table,
first_like_digit,
N[0:i] + '0' * len(N[i:]))
else:
c = chr(ord(c) + 1)
N = N[0:i] + c + N[i + 1:]
return N
def main():
"""Main function."""
dislike_digits_table = [False for _ in range(10)]
N, _ = sys.stdin.readline().split(' ')
digits = map(int, sys.stdin.readline().split(' '))
for digit in digits:
dislike_digits_table[digit] = True
first_like_digit = str(next(i for i, v
in enumerate(dislike_digits_table)
if not v))
print(solve(dislike_digits_table, first_like_digit, N))
if __name__ == '__main__':
sys.exit(main()) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s025045529 | p04045 | Wrong Answer | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""042-c"""
import sys
def solve(dislike_digits_table, first_like_digit, number):
"""Solve."""
if dislike_digits_table[int(number[0])]:
while dislike_digits_table[int(number[0])]:
if number[0] == '9':
number = '10' + number[1:]
else:
number = "{0}{1}".format(chr(ord(number[0]) + 1), number[1:])
number = number.replace(number[1:], first_like_digit * (len(number) - 1))
return number
def main():
"""Main function."""
dislike_digits_table = [False for _ in range(10)]
N, _ = sys.stdin.readline().split(' ')
digits = map(int, sys.stdin.readline().split(' '))
for digit in digits:
dislike_digits_table[digit] = True
first_like_digit = str(next(i for i, v
in enumerate(dislike_digits_table)
if not v))
for i, d in enumerate(N):
if dislike_digits_table[int(d)]:
N = N.replace(N[i:], solve(dislike_digits_table, first_like_digit, N[i:]))
break
print(N)
if __name__ == '__main__':
sys.exit(main()) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s017784026 | p04045 | Wrong Answer | import sys
N,K = list(map(int,input().split()))
D = input().split()
while True:
for i in range(len(str(N))):
if str(N)[i] in D:
break
else:
print(N)
sys.exit()
N += 1 | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s118057344 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = list(map(int, input().split()))
L = [i for i in range(10) if i not in D]
A = [i for i in L]
for i in L:
for j in L:
A.append(10*i+j)
for i in L:
for j in L:
for k in L:
A.append(100*i+10*j+k)
for i in L:
for j in L:
for k in L:
for l in L:
A.append(1000*i+100*j+10*k+l)
A.sort()
for i in A:
if i >= N:
print(i)
break | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s030270426 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = list(map(int, input().split()))
L = [i for i in range(10) if i not in D]
A = [i for i in L]
for i in L:
for j in L:
A.append(10*i+j)
for i in L:
for j in L:
for k in L:
A.append(100*i+10*j+k)
for i in L:
for j in L:
for k in L:
for l in L:
A.append(1000*i+100*j+10*k+l)
for i in A:
if i >= N:
print(i)
break | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s353359937 | p04045 | Wrong Answer | N, K = map(int, input().split())
D = list(map(int, input().split()))
L = [i for i in range(10) if i not in D]
A = [i for i in L]
for i in L:
for j in L:
A.append(10*i+j)
for i in L:
for j in L:
for k in L:
A.append(100*i+10*j+k)
for i in L:
for j in L:
for k in L:
for l in L:
A.append(1000*i+100*j+10*k+l)
for i in A:
if i >= N:
print(N)
break | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s149473051 | p04045 | Wrong Answer | #! python3
import sys
N, K = [int(x) for x in input().strip().split(' ')]
dislikes = set([int(x) for x in input().strip().split(' ')])
for i in range(10):
if i not in dislikes:
m_like = i
break
N = str(N)
if int(N[0]) == 9 and 9 in dislikes:
N = '10'+N[1:]
if 1 not in dislikes and 0 not in dislikes:
print('10'+str(m_like)*(len(N)-2))
sys.exit(0)
r = ''
for i in range(len(N)):
#print(N[i])
c = int(N[i])
if c in dislikes:
while c < 10 and c in dislikes:
c += 1
r += str(c)
break
r += str(c)
r += str(m_like) * (len(N)-1-i)
print(r) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
s048428434 | p04045 | Wrong Answer | #! python3
N, K = [int(x) for x in input().strip().split(' ')]
dislikes = set([int(x) for x in input().strip().split(' ')])
for i in range(10):
if i not in dislikes:
m_like = i
break
N = str(N)
if int(N[0]) == 9 and 9 in dislikes:
N = '10'+N[1:]
r = ''
for i in range(len(N)):
#print(N[i])
c = int(N[i])
if c in dislikes:
while c < 10 and c in dislikes:
c += 1
r += str(c)
break
r += str(c)
r += str(m_like) * (len(N)-1-i)
print(r) | 1000 8
1 3 4 5 6 7 8 9
| 2000
| <span class="lang-en">
<p>Score : <var>300</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p>
<p>She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p>
<p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p>
<p>Find the amount of money that she will hand to the cashier.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var> 1 ≦ N < 10000</var></li>
<li><var> 1 ≦ K < 10</var></li>
<li><var> 0 ≦ D_1 < D_2 < … < D_K≦9</var></li>
<li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>1000 8
1 3 4 5 6 7 8 9
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>2000
</pre>
<p>She dislikes all digits except <var>0</var> and <var>2</var>.</p>
<p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p>
</section>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 2</h3><pre>9999 1
0
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 2</h3><pre>9999
</pre></section>
</div>
</span> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.