submission_id string | problem_id string | status string | code string | input string | output string | problem_description string |
|---|---|---|---|---|---|---|
s917205130 | p04045 | Runtime Error | import bisect
#find set of numbers iroha like
tmp = raw_input("").split(' ')
n = int(tmp[0])
k = int(tmp[1])
tmp = raw_input("")
exclude_set = map(int, tmp.split(' '))
include_set = []
for i in range(0, 10):
if i not in exclude_set:
include_set.append(i)
#print include_set
n_digits = []
while n > 0:
n_digits.append(n%10)
n = int(n/10)
out = []
j = 0
#print include_set
while j < len(n_digits):
tmp = bisect.bisect_left(include_set, n_digits[j])
#print tmp
out.append(str(include_set[tmp]))
j += 1
print int(''.join(out)[::-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> |
s716111242 | p04045 | Runtime Error | N, K = map(int, input().split())
D = list(map(int, input().split()))
D_ALL = [0,1,2,3,4,5,6,7,8,9]
# 使える値
like = sorted(list(set(D_ALL) - set(D)))
small = like[0]
is_inc = False
out = ""
for i, s in enumerate(str(N)):
num = int(s)
for i2, like_num in enumerate(like):
if is_inc:
out += str(small)
break
if like_num >= num:
out += str(like_num)
if like_num > num:
is_inc = True
break
if i2 == len(like) - 1 and i == 0:
out = 1
out += str(small)
is_inc = True
print(out) | 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> |
s690688724 | p04045 | Runtime Error | is_inc = False
out = ""
for i, s in enumerate(str(N)):
num = int(s)
for i2, like_num in enumerate(like):
if is_inc:
out += str(small)
break
if like_num >= num:
out += str(like_num)
if like_num > num:
is_inc = True
break
if i2 == len(like) - 1 and i == 0:
out = str(small) + str(small)
is_inc = True | 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> |
s592879098 | p04045 | Runtime Error | n, k = input().split()
a = input().split()
n = int(n)
for i in range(10000-n):
c = str(n+i)
for j in a:
if j in c:
break
else:
ans = c
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> |
s709085808 | p04045 | Runtime Error | n,k=[s for s in input().split()]
hate=[]
like=[]
for i in range(k): #hate取得
hate.extend(input().split())
for i in range(1,10): #like取得
if i in hate:
like.append(i)
pointer=0
for ichi in like: #1桁の場合
if ichi>=n:
kane=ichi
pointer=1
break
if pointer==0: #2桁の場合
for ju in like:
for ichi in like:
if ju*10+ichi>=n:
kane=ju*10+ichi
pointer=1
break
if pointer==0: #3桁の場合
for hyaku in like:
for ju in like:
for ichi in like:
if hyaku*100+ju*10+ichi>=n:
kane=hyaku*100+ju*10+ichi
pointer=1
break
if pointer==0: #4桁の場合
for sen in like:
for hyaku in like:
for ju in like:
for ichi in like:
if sen*1000+hyaku*100+ju*10+ichi>=n:
kane=sen*1000+hyaku*100+ju*10+ichi
pointer=1
break
if pointer==1:
print(kane)
else:
print("Error!!") | 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> |
s459505948 | p04045 | Runtime Error | import sys
def main():
input=sys.stdin.readline
N,K=map(int,input().split())
D=list(map(int,input().split()))
L=[]
for i in range(10):
if i not in D:
L.append(i)
for p in L:
if len(str(N))==1:
if p>=N:
print(p)
return
else:
for q in L:
if len(str(N))==2:
pay=p*10+q
if pay>=N:
print(pay)
return
else:
for r in L:
if len(str(N))==3:
pay=p*100+q*10+r
if pay>=N:
print(pay)
return
else:
for s in L:
pay=p*1000+q*100+r*10+s
if pay>=N:
print(pay)
return
if L[0]==0:
print(L[1]*10**len(str(N)))
else:
print("".join([L[0] for _ in range(len(str(N)))]))
return
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> |
s339589510 | p04045 | Runtime Error | def main():
input=sys.stdin.readline
N,K=map(int,input().split())
D=list(map(int,input().split()))
L=[]
for i in range(10):
if i not in D:
L.append(i)
for p in L:
if len(str(N))==1:
if p>=N:
print(p)
return
else:
for q in L:
if len(str(N))==2:
pay=p*10+q
if pay>=N:
print(pay)
return
else:
for r in L:
if len(str(N))==3:
pay=p*100+q*10+r
if pay>=N:
print(pay)
return
else:
for s in L:
pay=p*1000+q*100+r*10+s
if pay>=N:
print(pay)
return
if L[0]==0:
print(L[1]*10**len(str(N)))
else:
print("".join([L[0] for _ in range(len(str(N)))]))
return
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> |
s125984197 | p04045 | Runtime Error | def UnlikeNum(nums,price):
for num in nums:
if(str(num) in str(price)):
return True
return False
N, K = map(int,input().split())
D = [int(input()) for k in range(K)]
while(UnlikeNum(D,N)):
N+=1
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> |
s145477488 | p04045 | Runtime Error | # -*- coding: utf-8 -*-
price, K = map(int, input().split())
kirai_data =list(input().split())
#print(set(data))
lst = list(range(price,10001))
for min in lst:
shugo = set(data) & set(list(str(min)))
if len(shugo) != 0 :
continue
else:
#print(price)
print(min)
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> |
s225604396 | p04045 | Runtime Error | #import sys
#input = sys.stdin.readline
from itertools import product
def main():
N, K = map( int, input().split())
D = list( map( int, input().split()))
NN = list( map( int, str(N)))
A = [ i for i in range(10) if i not in D]
for i in range(1,6):
for p in product(A, repeat = i):
now = 0
for j in range(i):
now = now*10+p[j]
if now >= N:
ANS.append(now)
print( min(ANS))
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> |
s005501175 | p04045 | Runtime Error | #import sys
#input = sys.stdin.readline
def main():
N, K = map( int, input().split())
D = list( map( int, input().split()))
NN = list( map( int, str(N)))
A = [ i for i in range(10) if i not in D]
l = len(NN)
ANS = []
now = 0
MIN = [0, A[0], A[0]*11, A[0]*111, A[0]*1111]
check = 0
for i in range(l):
for a in A:
if a > NN[0]:
ANS.append(now*10**(l-i)+a*10**(l-1-i) + MIN[l-1-i])
now = now*10+a
break
elif a == NN[0]:
now = now*10+NN[0]
check += 1
if check == l:
ANS.append(now)
print( min(ANS))
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> |
s021360089 | p04045 | Runtime Error | N, K = map(int, input().split())
D = list(map(int, input().split()))
A = [i for i in range(10)]
A = set(A) - set(D)
A = list(A)
A.sort()
S = str(N)
s = ''
for i in range(len(S)):
for j in range(len(A)):
if int(S[i]) <= A[j]:
s += str(A[j])
break
if len(s) == len(S):
print(s)
else:
if A[0] == 0:
s = str(A[1])
for i in range(len(S)):
s += str(A[0])
else:
s = str(A[0])
for i in range(len(S)):
s += str(A[1])
print(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> |
s122915718 | p04045 | Runtime Error | N, K = map(int, input().split())
D = list(map(int, input().split()))
A = [i for i in range(10)]
A = set(A) - set(D)
A = list(A)
A.sort()
S = str(N)
s = ''
for i in range(len(S)):
for j in range(len(A)):
if int(S[i]) <= A[j]:
s += str(A[j])
break
if len(s) == len(S):
print(s)
else:
if A[0] == 0:
s = A[1]
for i in range(len(S)):
s += A[0]
else:
s = A[0]
for i in range(len(S)):
s += A[1]
print(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> |
s164706537 | p04045 | Runtime Error | N,K = map(int,input().split())
D = set(map(int,input().split()))
A = {1,2,3,4,5,6,7,8,9,0}
N_list = [int(c) for c in str(N)]
use = sorted(list(A - D))
ans = [max(use) for i in range(len(N_list))]
mapans = map(str,ans)
x = int(''.join(mapans))
if N == x:
print(x)
elif N > x:
if use[0]!= 0:
ans = [use[0] for i in range(len(N_list)+1)]
else:
ans = [use[0] for i in range(len(N_list))+1]
ans[0] = use[1]
mapans = map(str,ans)
x = int(''.join(mapans))
else:
if use[0]!= 0:
ans = [use[0] for i in range(len(N_list))]
else:
ans = [use[0] for i in range(len(N_list))]
ans[0] = use[1]
mapans = map(str,ans)
x = int(''.join(mapans))
j = 0
i = 0
while x < N:
if ans[j] > N_list[j]:
for k in range(len(ans)-j-1):
ans[k] = min(use)
elif ans[j] == N_list[j]:
i = 0
j+=1
else:
i += 1
ans[j] = use[i]
mapans = map(str,ans)
x = int(''.join(mapans))
print(x)
| 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> |
s768629878 | p04045 | Runtime Error | N,K = map(int,input().split())
D = set(map(int,input().split()))
A = {1,2,3,4,5,6,7,8,9,0}
N_list = [int(c) for c in str(N)]
use = sorted(list(A - D))
ans = [max(use) for i in range(len(N_list))]
mapans = map(str,ans)
x = int(''.join(mapans))
if N == x:
print(x)
elif N > x:
if use[0]!= 0:
ans = [use[0] for i in range(len(N_list)+1)]
else:
ans = [use[0] for i in range(len(N_list))+1]
ans[0] = use[1]
mapans = map(str,ans)
x = int(''.join(mapans))
else:
if use[0]!= 0:
ans = [use[0] for i in range(len(N_list))]
else:
ans = [use[0] for i in range(len(N_list))]
ans[0] = use[1]
mapans = map(str,ans)
x = int(''.join(mapans))
j = 0
i = 0
while x < N:
if ans[j] > N_list[j]:
for k in range(len(ans)-j-1):
ans[k] = min(use)
elif ans[j] == N_list[j]:
i = 0
j+=1
else:
ans[j] = use[i]
i += 1
mapans = map(str,ans)
x = int(''.join(mapans))
print(x)
| 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> |
s420134180 | p04045 | Runtime Error | N,K = map(int,input().split())
D = set(map(int,input().split()))
A = {1,2,3,4,5,6,7,8,9,0}
N_list = [int(c) for c in str(N)]
use = sorted(list(A - D))
ans = [max(use) for i in range(len(N_list))]
mapans = map(str,ans)
x = int(''.join(mapans))
if N == x:
print(x)
elif N > x:
if use[0]!= 0:
ans = [use[0] for i in range(len(N_list)+1)]
else:
ans = [use[0] for i in range(len(N_list))+1]
ans[0] = use[1]
mapans = map(str,ans)
x = int(''.join(mapans))
else:
if use[0]!= 0:
ans = [use[0] for i in range(len(N_list))]
else:
ans = [use[0] for i in range(len(N_list))]
ans[0] = use[1]
mapans = map(str,ans)
x = int(''.join(mapans))
j = 0
i = 0
print(x)
while x < N:
if ans[j] > N_list[j]:
for k in range(len(ans)-j-1):
ans[k] = min(use)
elif ans[j] == N_list[j]:
i = 0
j+=1
else:
ans[j] = use[i]
i += 1
mapans = map(str,ans)
x = int(''.join(mapans))
print(x)
| 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> |
s187322920 | p04045 | Runtime Error | N,K = map(int,input().split())
D = set(map(int,input().split()))
A = {1,2,3,4,5,6,7,8,9,0}
N_list = [int(c) for c in str(N)]
use = sorted(list(A - D))
ans = [max(use) for i in range(len(N_list))]
mapans = map(str,ans)
x = int(''.join(mapans))
if N == x:
print(x)
elif N > x:
if use[0]!= 0:
ans = [use[0] for i in range(len(N_list)+1)]
else:
ans = [use[0] for i in range(len(N_list))+1]
ans[0] = use[1]
mapans = map(str,ans)
x = int(''.join(mapans))
else:
if use[0]!= 0:
ans = [use[0] for i in range(len(N_list))]
else:
ans = [use[0] for i in range(len(N_list))]
ans[0] = use[1]
mapans = map(str,ans)
x = int(''.join(mapans))
j = 0
i = 0
print(x)
while x < N:
if ans[j] > N_list[j]:
for k in range(len(ans)-j-1):
ans[k] = min(use)
elif ans[j] == N_list[j]:
i = 0
j+=1
else:
ans[j] = use[i]
# i += 1
# print(use)
# print(ans[j])
mapans = map(str,ans)
x = int(''.join(mapans))
print(x)
| 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> |
s252731859 | p04045 | Runtime Error | N,K = map(int,input().split())
D = set(map(int,input().split()))
A = {1,2,3,4,5,6,7,8,9,0}
N_list = [int(c) for c in str(N)]
use = sorted(list(A - D))
ans = [max(use) for i in range(len(N_list))]
mapans = map(str,ans)
x = int(''.join(mapans))
if N == x:
print(x)
elif N > x:
if use[0]!= 0:
ans = [use[0] for i in range(len(N_list)+1)]
else:
ans.append(use[1])
ans = [use[0] for i in range(len(N_list))]
mapans = map(str,ans)
x = int(''.join(mapans))
print(x)
else:
if use[0]!= 0:
ans = [use[0] for i in range(len(N_list))]
else:
ans.append(use[1])
ans = [use[0] for i in range(len(N_list)-1)]
mapans = map(str,ans)
x = int(''.join(mapans))
j = 0
i = 0
while x < N:
if ans[j] > N_list[j]:
for k in range(len(ans)-j-1):
ans[k] = min(use)
elif ans[j] == N_list[j]:
i = 0
j+=1
else:
ans[j] = use[i]
i += 1
mapans = map(str,ans)
x = int(''.join(mapans))
print(x)
| 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> |
s454240637 | p04045 | Runtime Error | N, K = map(int, input().split())
num_exclude = list(map(int, input().split()))
dec_num = [i for i in range(0, 10)]
able_use_num_lis = list(map(str, set(dec_num) - set(num_exclude)))
num_len = len(str(N))
output_list = []
def dfs(cur, num, able_use_num_lis):
if num != '':
if int(num) >= N:
output_list.append(int(num))
if len(str(N)) == cur:
return
for add_num in able_use_num_lis:
ret = dfs(cur + 1, num + add_num, able_use_num_lis)
return output_list
print(min(dfs(0, '', able_use_num_lis))) | 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> |
s752835320 | p04045 | Runtime Error | n,k=map(int,input().split())
D=list(map(int, input().split()))
num=[0,1,2,3,4,5,6,7,8,9]
M=[]
N=list(str(n))
for i in D:
num.remove(int(i))
for k in num:
if k>=int(N[0]) and k!=0:
M.append(str(k))
N.pop(0)
for j in N:
m=[]
for l in num:
if l>=int(j):
m.append(l)
M.append(str(min(m)))
print("".join(M)) | 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> |
s426861214 | p04045 | Runtime Error |
n, m = [ int(v) for v in input().split() ]
num_list = [ v for v in input().split() ]
t = n
while:
if all([ ( v not in num_list ) for v in list(str(i))]):
print(i)
break
t += 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> |
s453114080 | p04045 | Runtime Error | def equal(n, available):
return n in available
def less(n, available):
return n < sorted(available)[0]
def greater(n, available):
return n > sorted(available, reverse=True)[0]
#less(n, available) == True であること
def upper_next(n, available):
for v in sorted(available):
if n < v:
return v
return 1/0
n_str, _ = [v for v in input().split()]
n_s = [0]
n_s.extend([int(n_str[i:i+1]) for i in range(len(n_str))])
d_s = [int(v) for v in input().split()]
available = set(list(range(10))) - set(d_s)
#print("n", n_s, "d", d_s, "u", available)
min_available = sorted(available)[0]
ans = [0]
ans.extend([min_available] * (len(n_s) - 1))
eq = True
for i in range(1, len(n_s)):
if eq:
if equal(n_s[i], available):
ans[i] = n_s[i]
continue
else:
eq = False
if less(n_s[i], available):
ans[i] = upper_next(n_s[i], available)
#残りは最小値詰め
break
else:
for j in range(i - 1, -1, -1):
if greater(ans[j], available):
ans[j] = min_available
else:
ans[j] = upper_next(ans[j], available)
break
break
begin = 0
if ans[0] == 0:
begin = 1
ans_val = "".join(map(lambda x:str(x), ans[begin:]))
print(ans_val) | 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> |
s651105844 | p04045 | Runtime Error | n,m=map(int,input().split())
l=list(map(int,input().split()))
b=True
while b:
b1=False
l1=list(str(n))
for i in l1:
if i in l:
b1=True
if b1=False:
b=True
print(n)
break
else:
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> |
s461871435 | p04045 | Runtime Error | N, K = input().split()
D = [i for i in input().split()]
NUM = '0123456789'
num = [i for i in NUM if i not in D]
ans = ''
for j in range(len(N)):
if int(N[j]) > int(max(num)):
ans = ''
ans += num[1]
ans = int(ans.ljust(len(N)+1, min(num)))
break
for i in range(len(num)):
if int(N[j]) <= int(num[i]):
ans += num[i]
break
if int(ans.ljust(len(N), min(num))) > int(N):
ans = int(ans.ljust(len(N), min(num)))
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> |
s591391516 | p04045 | Runtime Error | N, K = input().split()
D = [i for i in input().split()]
NUM = '0123456789'
num = [i for i in NUM if i not in D]
ans = ''
for j in range(len(N)):
if int(ans.ljust(len(N), min(num))) > int(N):
ans = int(ans.ljust(len(N), min(num)))
break
elif int(N[j]) <= int(max(num)):
ans += num[1]
ans = int(ans.ljust(len(N)+1, min(num)))
break
for i in range(len(num)):
if int(N[j]) <= int(num[i]):
ans += num[i]
break
print(ans)
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> |
s581589483 | p04045 | Runtime Error | N, K = input().split()
D = [i for i in input().split()]
NUM = '0123456789'
num = [i for i in NUM if i not in D]
ans = ''
for j in range(len(N)):
if int(ans.ljust(len(N), min(num))) > int(N):
ans = int(ans.ljust(len(N), min(num)))
break
elif int(N[j]) <= int(max(num)):
ans += num[1]
ans = int(ans.ljust(len(N)+1, min(num)))
break
for i in range(len(num)):
if int(N[j]) <= int(num[i]):
ans += num[i]
print(ans)
break
print(ans)
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> |
s179882572 | p04045 | Runtime Error | N, K = input().split()
D = [i for i in input().split()]
NUM = '0123456789'
num = [i for i in NUM if i not in D]
ans = ''
print(num)
for j in range(len(N)):
if int(ans.ljust(len(N), min(num))) > int(N):
ans = int(ans.ljust(len(N), min(num)))
break
elif int(N[j]) <= int(max(num)):
ans += num[1]
ans = int(ans.ljust(len(N)+1, min(num)))
break
for i in range(len(num)):
if int(N[j]) <= int(num[i]):
ans += num[i]
print(ans)
break
print(ans)
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> |
s131929278 | p04045 | Runtime Error | N, K = input().split()
D = [i for i in input().split()]
NUM = '0123456789'
num = [i for i in NUM if i not in D]
ans = ''
a = []
for j in range(len(N)):
for i in range(len(num)):
if int(N[j]) <= int(num[i]):
ans += num[i]
break
a.append(int(ans))
ans = ''
for j in range(len(N)):
if j == 0:
for i in range(len(num)):
if int(N[j]) <= int(num[i]):
ans += num[i]
break
else:
ans += min(num)
a.append(int(ans))
print(min(a) if min(a) >= int(N) else max(a)) | 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> |
s843317532 | p04045 | Runtime Error | N,K = map(str, input().split())
D = set(map(int,input().split()))
E = {0,1,2,3,4,5,6,7,8,9}
F = E - D
f = max(F)
swith = 0
if 0 in F:
g =str(list(F)[1])
else:
g = str(min(F))
list = N.split()
length = len(N)
for n in range(length):
if int(N[n]) in D:
swith = 1
for l in range(n+1,length):
list[l] = str(min(F))
if int(N[n]) >= f:
list[n] = str(min(F))
if n == 0:
list.insert(0,str(g))
else:
H = {}
H = set(range(int(N[n]) + 1))
list[n] = str(min(F - H))
if swith == 1:
break
print(''.join(list)) | 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> |
s104791800 | p04045 | Runtime Error | import sys
input = sys.stdin.readline
N, K = map(int, input().split())
L = [int(v) for v in input().split()]
no = [v for v in range(10) if v not in L]
s = list(map(int, str(N)))
for i in range(len(s)):
if i == 0:
if s[i] in L:
s[i] = min([v for v in no if v != 0 and v > s[i]])
else:
if s[i] in L:
s[i] = min([v for v in no if v > s[i]])
print("".join(map(str, 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> |
s768871058 | p04045 | Runtime Error | import itertools
D=[]
DN=[]
the_string = input()
N, K = the_string.split()
K= int(K)
for x in range(K):
D.append(input())
for x in range(10):
if(str(x) in D):
continue
else:
DN.append(x)
DList=list(itertools.product(DN,repeat=len(N)))
res=0
for x in DList:
num1=int(''.join(map(str, x)))
if num1>=int(N):
res=num1
break
if(res<int(N)):
DList=list(itertools.product(DN,repeat=len(N)+1))
res=0
for x in DList:
num1=int(''.join(map(str, x)))
if num1>=int(N):
res=num1
break
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> |
s209159597 | p04045 | Runtime Error | import itertools
D=[]
DN=[]
N= input()
K= int(input())
for x in range(K):
D.append(input())
for x in range(10):
if(str(x) in D):
continue
else:
DN.append(x)
DList=list(itertools.product(DN,repeat=len(N)))
res=0
for x in DList:
num1=int(''.join(map(str, x)))
if num1>=int(N):
res=num1
break
if(res<int(N)):
DList=list(itertools.product(DN,repeat=len(N)+1))
res=0
for x in DList:
num1=int(''.join(map(str, x)))
if num1>=int(N):
res=num1
break
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> |
s230869025 | p04045 | Runtime Error | #C問題
N, K = map(int, input().split())
D = []
D = list(map(int, input().split()))
num = []
for i in range(10):
if i not in D:
num.append(i)
N_num = []
while True:
if N ==0:
break
N_num.append(N%10)
N = N//10
N_num.sort(reverse = True)
ans = []
for i in N_num:
for k in range(len(num)):
if num[k] >= i:
ans.append(num[k])
break
elif k == len(num):
ans.append(k)
ans[k-1] = num[k+1]
map(str, ans)
ans = int("".join(map(str, ans)))
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> |
s112188184 | p04045 | Runtime Error | N, K = map(int, input().split())
D = []
D = list(map(int, input().split()))
num = []
for i in range(10):
if i not in D:
num.append(i)
N_num = []
while True:
if N ==0:
break
N_num.append(N%10)
N = N//10
N_num.sort(reverse = True)
ans = []
for i in N_num:
for k in num:
if k >= i:
ans.append(k)
break
map(str, ans)
ans = int("".join(map(str, ans)))
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> |
s271677643 | p04045 | Runtime Error | def pay_by_iroha(price, dislike_digits):
for n in range(10000):
if n >= price and len(set(int(i) for i in str(n))&dislike_digits)==0:
return n
def main():
n, _ = (int(i) for i in input().split())
dgs = set(int(i) for i input().split())
print(pay_by_iroha(n, dgs))
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> |
s446076742 | p04045 | Runtime Error | white_num_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
N, K = map(int, input().split())
black_num_list = list(map(int, input().split()))
white_num_list = list(set(white_num_list).difference(set(black_num_list)))
num_combination = list(itertools.combinations_with_replacement(white_num_list, len(str(N))))
num_list = []
for num in num_combination:
if num[0] == 0:
continue
num_list.append(int(''.join(map(str, num))))
num_list = sorted(num_list)
def price(N, num_list, white_num_list):
for num in num_list:
if num >= N:
return num
if 0 in white_num_list:
white_num_list.remove(0)
placeholder = str(min(white_num_list))
return int(placeholder * (len(str(N)) + 1))
print(price(N, num_list, white_num_list)) | 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> |
s946728388 | p04045 | Runtime Error | import os
N, K = map(int, input().split(' '))
d_list = input().split(' ')
for i in range(10):
for j in range(10):
for k in range(10):
for l in range(10):
number = i * 1000 + j * 100 + k * 10 + l
result = set(list(str(number)))
if set(d_list) & result != set():
continue
if number >= N:
print(number)
os._exit(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> |
s917734765 | p04045 | Runtime Error | n, k = map(int, input().split())
d = set([str(i) for i in input().split()])
c = 0
for i in range(1, 11):
c += n
t = set(list(str(c)))
if len(d & t) == 0:
ans = c
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> |
s786946420 | p04045 | Runtime Error | n, k = map(int, input().split())
d = set([str(i) for i in input().split()])
c = 0
for i in range(1, 10):
c += n
t = set(list(str(c)))
if len(t & d) == 0:
ans = c
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> |
s811749332 | p04045 | Runtime Error | # coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
n, k = map(str, input().split())
a = list(map(int, input().split()))
p = []
for i in range(0, 10):
if i in a:
pass
else:
p.append(i)
p.sort()
count = 0
for i in list(n):
count *= 10
j = bisect.bisect_left(p, int(i))
if p[j] < int(i):
count += p[j + 1]
else:
count += p[j]
print(count)
| 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> |
s044894074 | p04045 | Runtime Error | n,k=map(int,input().split())
a=list(map(int,input().split()))
m=[]
for i in range(10):
if i not in a:
m.append(i)
k=0
for a in m:
for b in m:
for c in m:
for d in m:
for e in m:
num=a*10000+b*1000+c*100+d*10+e
if k==0 and num>=n:
print(num)
k=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> |
s543854287 | p04045 | Runtime Error | n,k=map(int,input().split())
a=list(map(int,input().split()))
m=[]
for i in range(10):
if i not in a:
m.append(i)
k=0
for a in m:
for b in m:
for c in m:
for d in m:
num=a*1000+b*100+c*10+d
if k==0 and num>=n:
ans=num
k=1
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> |
s966245080 | p04045 | Runtime Error | n,k=map(int,input().split())
a=list(map(int,input().split()))
m=[]
for i in [0,1,2,3,4,5.6,7,8,9]:
if i not in a:
m.append(i)
k=0
for a in m:
for b in m:
for c in m:
for d in m:
num=a*1000+b*100+c*10+d
if k==0 and num>=n:
ans=num
k=1
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> |
s911867288 | p04045 | Runtime Error | n,k=map(int,input().split())
a=list(map(int,input().split()))
m=[]
for i in [0,1,2,3,4,5.6,7,8,9]:
if i not in a:
m.append(i)
k=0
for a in m:
for b in m:
for c in m:
for d in m:
if k:
break
num=a*1000+b*100+c*10+d
if num>=n:
ans=num
k=1
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> |
s898222592 | p04045 | Runtime Error | N,K = map(str,input().split())
D = list(map(int,input().split()))
nums = [x for x in range(10)]
nots = [i for i in nums if i not in D]
ans = ""
for j in range(len(N)):
for k in nots:
if int(N[j])<=k:
ans+=str(k)
break
print(int(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> |
s583710153 | p04045 | Runtime Error | import sys
from itertools import product
def main():
input = sys.stdin.readline
N, K = map(str, input().split())
D = list(map(str, input().split()))
nums = set([str(i) for i in range(10)])
safe = sorted(list(nums - set(D)))
digit = len(str(N))
safe_num = list(product(safe, repeat=digit))
ans = 10**5
for n in safe_num:
m = int(''.join(n))
l = int(safe[0] + ''.join(n))
s = int(safe[1] + ''.join(n))
if m >= int(N):
ans = min(ans, m)
if l >= int(N):
ans = min(ans, l)
if s >= int(N):
ans = min(ans, s)
return ans
if __name__ == '__main__':
print(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> |
s205901468 | p04045 | Runtime Error | import sys
def main():
input = sys.stdin.readline
N, K = map(int, input().split())
D = list(map(int, input().split()))
safe = list(set(range(10)) - set(D))
safe = sorted(safe)
n = [c for c in str(N)]
for i in range(len(n)):
if int(n[i]) in safe:
continue
for s in safe:
if s > int(n[i]):
n[i] = str(s)
replaced = i
break
break
for i in range(replaced+1, len(n)):
n[i] = str(safe[0])
return ''.join(n)
if __name__ == '__main__':
print(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> |
s191074333 | p04045 | Runtime Error | num =set([0,1,2,3,4,5,6,7,8,9])
n,k = input().split()
d = list(map(int,input().split()))
a = list(num - set(d))
a.sort()
ans =[]
for i in range(len(n)):
for j in a:
if int(n[i]) <= j:
ans.append(a[i])
break
if a[-1] < int(n[i]):
ans.append(a[0])
l = map(str,ans)
b = "".join(l)
if int(b) < int(n):
if a[0] != 0:
print(a[0]*(10**(len(n)))+int(b))
else:
print(a[1]*(10**(len(n))) + int(b))
else:
print(int(b)) | 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> |
s740333544 | p04045 | Runtime Error | N, K = map(int, input().split())
dislike = list(map(int, input().split()))
for i in range(N, 10*N+1):
num = list(map(int,str(i)))
match = list(set(i) & set(dislike))
if len(match)==0:
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> |
s461079728 | p04045 | Runtime Error | n, k = (int(_) for _ in input().split())
a = [int(_) for _ in input().split()]
like = [i for i in range(10)]
pay = []
for i in str(n):
while int(i)%10 in a:
i = int(i) + 1
pay.append(str(i%10))
total = ''
for i in pay:
total += i
if n > int(total):
total += str(like[0])
print(int(total)) | 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> |
s326719303 | p04045 | Runtime Error | n, k = (int(_) for _ in input().split())
a = [int(_) for _ in input().split()]
like = [i for i in range(10)]
pay = []
for i in a:
like.remove(i)
print(like)
for i in str(n):
while int(i)%10 in a:
i = int(i) + 1
pay.append(str(i%10))
total = ''
for i in pay:
total += i
if n > int(total):
total += str(like[0])
print(int(total)) | 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> |
s732108355 | p04045 | Runtime Error | N,K=input().split()
D=list(map(int,input().split()))
for i in N:
if int(i) in D:
N[i]+=1
else:
pass
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> |
s373136369 | p04045 | Runtime Error | N,K=map(int,input().split())
D=list(map(int,input().split()))
NL=len(str(N))
ans=[]
allnum=list(range(10))
use=list(set(allnum)^set(D))
for i in range(NL):
a=int(str(N)[i])
for j in use:
if a<=j:
ans.append(j)
break
else:
continue
if ans[0]==0:
ans[0]=use[1]
else:
pass
print(int(''.join(map(str,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> |
s141680875 | p04045 | Runtime Error | # 0〜9
l=list(range(10))
# 入力
N,K=map(str,input().split())
l2=list(map(int,input().split()))
ans=''
f=False
# 使用可能な数字を求める
for x in l2:
l.remove(x)
# Nと桁数が一致する場合
if int(N[0])<l[-1]:
for i in range(len(N)):
for x in l:
if f:
ans+=str(x)
break
elif int(N[i])<x:
f=True
ans+=str(x)
break
elif int(N[i])==x:
ans+=str(x)
break
# Nと桁数が一致する可能性がある場合
elif int(N[0])==l[-1]:
l3=list(N[1:])
l3=list(map(int,set(l3)))
l3.sort()
# Nと桁数が一致しない
if l3[-1]>l[-1]:
# 最上位は0以外の最小の数にする
if l[0]==0:
ans+=str(l[1])
ans+='0'*len(N)
else:
ans+=str(l[0])*(len(N)+1)
# Nと桁数が一致する
else:
for i in range(len(N)):
for x in l:
if f:
ans+=str(x)
break
elif int(N[i])<x:
f=True
ans+=str(x)
break
elif int(N[i])==x:
ans+=str(x)
break
# Nと桁数が一致しない場合
else:
# 最上位は0以外の最小の数にする
if l[0]==0:
ans+=str(l[1])
ans+='0'*len(N)
else:
ans+=str(l[0])*(len(N)+1)
# 出力
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> |
s948232026 | p04045 | Runtime Error | # 0〜9
l=list(range(10))
# 入力
N,K=map(str,input().split())
l2=list(map(int,input().split()))
ans=''
f=False
# 使用可能な数字を求める
for x in l2:
l.remove(x)
# Nと桁数が一致する場合
if int(N[0])<l[-1]:
for i in range(len(N)):
for x in l:
if f:
ans+=str(x)
break
elif int(N[i])<x:
f=True
ans+=str(x)
break
elif int(N[i])==x:
ans+=str(x)
break
# Nと桁数が一致する可能性がある場合
elif int(N[0])==l[-1]:
l3=list(N[1:])
l3=list(map(int,set(l3)))
l3.sort()
# Nと桁数が一致しない
if l3[-1]>l[-1]:
# 最上位は0以外の最小の数にする
if l[0]==0:
ans+=str(l[1])
ans+='0'*int(N)
else:
ans+=str(l[0])*(N+1)
# Nと桁数が一致する
else:
for i in range(len(N)):
for x in l:
if f:
ans+=str(x)
break
elif int(N[i])<x:
f=True
ans+=str(x)
break
elif int(N[i])==x:
ans+=str(x)
break
# Nと桁数が一致しない場合
else:
# 最上位は0以外の最小の数にする
if l[0]==0:
ans+=str(l[1])
ans+='0'*int(N)
else:
ans+=str(l[0])*(N+1)
# 出力
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> |
s478840158 | p04045 | Runtime Error | Num = [int(n) for n in input().rstrip().split()]
D = [int(n) for n in input().rstrip().split()]
for i in rang:e(Num[0],10000):
if len(set([str(n) for n in D]) & set(str(i))) == 0:
print(int(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> |
s200383898 | p04045 | Runtime Error | Num = [int(n) for n in input().rstrip().split()][0]
D = [int(n) for n in inut().rstrip().split()]
numberlist = [n if n not in D for n in range(9)]
anslist = []
for num in numberlist:
if num >= Num:
anslist.append(num)
else:pass
print(min(anslist))
| 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> |
s328592033 | p04045 | Runtime Error | import itertools
N,K = map(int,input().split())
D = list(map(int,input().split()))
#使用可能数字の取り出し
Num1 = []
for i in range(10):
if(i in D): continue
else: Num1.append(i)
#組み合わせ
Comb = []
n = len(str(N))
for i in range(n):
Comb.append(Num1)
Comb = list(itertools.product(*Comb))
for i in range(len(Comb)):
tmp = Comb[i]
tmp_num = ''
for j in range(n): tmp_num += str(tmp[j])
tmp_num = int(tmp_num)
if(N <= tmp_num):
ans = tmp_num
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> |
s225364593 | p04045 | Runtime Error | import itertools
N,K = map(int,input().split())
D = list(map(int,input().split()))
#使用可能数字の取り出し
Num = [1]*10 #index = num, 使用可能: 1,使用不可: 0
Num1 = [] #使用可能数字格納
for i in range(K):
Num[D[i]] = 0
for i in range(10):
if(Num[i] == 1):Num1.append(i)
#組み合わせ
Comb = []
n = len(str(N))
for i in range(n):
Comb.append(Num1)
Comb = list(itertools.product(*Comb))
for i in range(len(Comb)):
tmp = Comb[i]
tmp_num = ''
for j in range(n): tmp_num += str(tmp[j])
tmp_num = int(tmp_num)
if(N <= tmp_num):
ans = tmp_num
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> |
s608941100 | p04045 | Runtime Error | def irohas_obsession(N: int, K: int, D: list) -> int:
# D に含まれない最小の値
min_not_d = min(d for d in range(10) if d not in D)
min_not_d_and_not_zero = min(d for d in range(10) if d not in D and d != 0)
# 数字を各桁に分解する。
nums = []
while N > 0:
nums = [N % 10] + nums
N //= 10
# 上位の桁から見ていって最初に D に含まれる数字を探す。
# convert_idx = len(nums)
for i, n in enumerate(nums):
if n not in D:
# 変換の必要がない
continue
convert_idx = i
break
# print(convert_idx)
for i in range(convert_idx, -1, -1):
n = nums[i]
if n > 9:
n %= 10
if i > 0:
nums[i - 1] += 1
else:
nums = [min_not_d_and_not_zero] + nums
for d in range(n, 10):
# 変換先が n 以上 9 以下
if d in D:
# NG
continue
nums[i] = d
break
else:
# 変換先が n 未満
for d in range(n, 10):
if d in D:
# NG
continue
nums[i] = d
# 上位の桁に繰り上がりを伝搬
if i > 0:
nums[i - 1] += 1
else:
nums = [min_not_d_and_not_zero] + nums
# 残りの桁は D に含まれない最小の値に変換する。
nums = [min_not_d if n in D else n for n in nums]
ret = 0
digit = 1
# print(nums)
for n in reversed(nums):
ret += n * digit
digit *= 10
return ret
if __name__ == "__main__":
N, K = map(int, input().split())
D = [int(s) for s in input().split()]
ans = irohas_obsession(N, K, D)
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> |
s702061477 | p04045 | Runtime Error | def irohas_obsession(N: int, K: int, D: list) -> int:
# D に含まれない最小の値
min_not_d = min(d for d in range(10) if d not in D)
min_not_d_and_not_zero = min(d for d in range(10) if d not in D and d != 0)
# 数字を各桁に分解する。
nums = []
while N > 0:
nums = [N % 10] + nums
N //= 10
# 上位の桁から見ていって最初に D に含まれる数字を探す。
# convert_idx = len(nums)
for i, n in enumerate(nums):
if n not in D:
# 変換の必要がない
continue
convert_idx = i
break
# print(convert_idx)
for i in range(convert_idx, -1, -1):
n = nums[i]
if n > 9:
n %= 10
if i > 0:
nums[i - 1] += 1
else:
nums = [min_not_d_and_not_zero] + nums
for d in range(n, 10):
# 変換先が n 以上 9 以下
if d in D:
# NG
continue
nums[i] = d
break
else:
# 変換先が n 未満
for d in range(n, 10):
if d in D:
# NG
continue
nums[i] = d
# 上位の桁に繰り上がりを伝搬
if i > 0:
nums[i - 1] += 1
else:
nums = [min_not_d_and_not_zero] + nums
# 残りの桁は D に含まれない最小の値に変換する。
nums = [min_not_d if n in D else n for n in nums]
ret = 0
digit = 1
print(nums)
for n in reversed(nums):
ret += n * digit
digit *= 10
return ret
if __name__ == "__main__":
N, K = map(int, input().split())
D = [int(s) for s in input().split()]
ans = irohas_obsession(N, K, D)
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> |
s630252720 | p04045 | Runtime Error | def irohas_obsession(N: int, K: int, D: list) -> int:
# D に含まれない最小の値
min_not_d = min(d for d in range(10) if d not in D)
# 数字を各桁に分解する。
nums = []
while N > 0:
nums = [N % 10] + nums
N //= 10
# 上位の桁から見ていって最初に D に含まれる数字を探す。
# convert_idx = len(nums)
for i, n in enumerate(nums):
if n not in D:
# 変換の必要がない
continue
convert_idx = i
break
# print(convert_idx)
for i in range(convert_idx, -1, -1):
n = nums[i]
for d in range(n, 10):
# 変換先が n 以上 9 以下
if d in D:
# NG
continue
nums[i] = d
break
else:
# 変換先が n 未満
for d in range(n, 10):
if d in D:
# NG
continue
nums[i] = d
# 上位の桁に繰り上がりを伝搬
if i > 0:
nums[i - 1] += 1
else:
nums = [min_not_d] + nums
# 残りの桁は D に含まれない最小の値に変換する。
nums = [min_not_d if n in D else n for n in nums]
ret = 0
digit = 1
# print(nums)
for n in reversed(nums):
ret += n * digit
digit *= 10
return ret
if __name__ == "__main__":
N, K = map(int, input().split())
D = [int(s) for s in input().split()]
ans = irohas_obsession(N, K, D)
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> |
s340420510 | p04045 | Runtime Error | def irohas_obsession(N: int, K: int, D: list) -> int:
# D に含まれない最小の値
min_not_d = min(d for d in range(10) if d not in D)
# 数字を各桁に分解する。
nums = []
while N > 0:
nums = [N % 10] + nums
N //= 10
# 上位の桁から見ていって最初に D に含まれる数字を探す。
# convert_idx = len(nums)
for i, n in enumerate(nums):
if n not in D:
# 変換の必要がない
continue
convert_idx = i
break
# print(convert_idx)
for i in range(convert_idx, -1, -1):
n = nums[i]
for d in range(n, 10):
# 変換先が n 以上 9 以下
if d in D:
# NG
continue
nums[i] = d
break
else:
# 変換先が n 未満
for d in range(n, 10):
if d in D:
# NG
continue
nums[i] = d
# 上位の桁に繰り上がりを伝搬
if i > 0:
nums[i - 1] += 1
else:
nums = [min_not_d] + nums
# 残りの桁は D に含まれない最小の値に変換する。
nums = [min_not_d if n in D else n for n in nums]
ret = 0
digit = 1
print(nums)
for n in reversed(nums):
ret += n * digit
digit *= 10
return ret
if __name__ == "__main__":
N, K = map(int, input().split())
D = [int(s) for s in input().split()]
ans = irohas_obsession(N, K, D)
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> |
s432334079 | p04045 | Runtime Error | N,K=map(int,input().split())
D=list(map(int,input().split()))
def dfs(n):
if all(not(int(i) in D) for i in str(n)):
return n
return dfs(n+1)
print(dfs(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> |
s073727031 | p04045 | Runtime Error | # coding: UTF-8
N, _ = input().split()
dislike_nums = set(map(int, input().split()))
nums = set(range(10))
nums -= dislike_nums
for i in range(len(N)):
Ni = int(N[i])
larger_num = [n for n in nums if n >= Ni]
print(min(larger_num), end="")
print()
| 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> |
s374368397 | p04045 | Runtime Error | import sys
N, _ = map(int, input().split())
D = list(map(int, input().split()))
E = [str(i) for i in [0,1,2,3,4,5,6,7,8,9] if i not in D]
for n in N:
if not n in E:
for e in E:
if e>n:
n=e
sys.stdout.write(n)
break;
else:
sys.stdout.write(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> |
s429625303 | p04045 | Runtime Error | N,K = map(int,input().split())
D = {int(n) for n in input().split()}
for j in range(10000):
if N <= j:
L = {int(result) for result in str(j)}
if D.isdisjoint(L):
D_love = j
break
print(D_love)
| 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> |
s253526970 | p04045 | Runtime Error | N,K = map(int,input().split())
D = {int(n) for n in input().split()}
for j in range(10001):
if N <= j:
L = {int(result) for result in str(j)}
if D.isdisjoint(L):
D_love = j
break
print(D_love)
| 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> |
s623472986 | p04045 | Runtime Error | N,K = map(int,input().split())
D = {int(n) for n in input().split()}
a = {i for i in range(10)}
N_hate = a.difference(D)
for j in range(10001):
if N <= j:
L = {int(result) for result in str(j)}
if N_hate == L:
N_love = j
break
print(N_love)
| 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> |
s351592054 | p04045 | Runtime Error | N, K = map(int, input().split())
de_num = list(map(int, input().split()))
ok_num = []
cand_num = []
ans_num = []
for i in range(10):
if i not in de_num:
ok_num.append(i)
for i in ok_num:
for j in ok_num:
for k in ok_num:
for l in ok_num:
num = 1000*i + 100*j + 10*k + l
cand_num.append(num)
for cd in cand_num:
if cd >= N:
ans_num.append(cd)
print(min(ans_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> |
s904543504 | p04045 | Runtime Error | n,k=map(int,input().split())
d=list(map(int,input().split()))
l=[0,1,2,3,4,5,6,7,8,9]
for i in range(k):
l.remove(d[i])
L=[]
for j1 in range(len(l)):
for j2 in range(len(l)):
for j3 in range(len(l)):
for j4 in range(len(l)):
L.append(l[j1]*1000+l[j2]*100+l[j3]*10+l[j4])
for k in range(len(L)):
if L[k]>=n:
x=L[k]
break
print(x) | 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> |
s935033810 | p04045 | Runtime Error | import itertools
def main():
n,k = map(int, input().split())
ds = map(int, input().split())
canuse = [i for i in range(10)]
for d in ds: canuse.remove(d)
canuse = [str(c) for c in canuse]
digit = len(str(n))
x = [int("".join(a)) for a in itertools.product(canuse, repeat=digit) if int("".join(a))>=n]
print(min(x))
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> |
s593053584 | p04045 | Runtime Error | # encoding: utf-8
N, K = map(int, input().split())
D = list(map(int, input().split()))
Db = []
for Di in range(10):
if Di not in D: Db.append(Di)
# print("#", Db)
for level in range(6):
if N // (10 ** level) < 1: break
# print("#", level)
memo = [None] * (level * 10000)
def pay(pos, tmp):
# print("##", pos, tmp)
if pos > level or tmp >= N:
if tmp >= N:
# print("###", tmp)
return tmp
else: return 10000
elif memo[pos * 10000 + tmp] != None: return memo[pos * 10000 + tmp]
rets = []
for Dbi in Db:
add = Dbi * (10 ** pos)
rets.append(pay(pos + 1, tmp + add))
ret = min(rets)
if memo[pos * 10000 + tmp] == None: memo[pos * 10000 + tmp] = ret
return ret
print(pay(0, 0)) | 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> |
s419587123 | p04045 | Runtime Error | price, len_hate_set = map(int, input().split())
hate_set = set([int(i) for i in input().split()])
ans = 0
while True:
if all(map(lambda x: int(x) in set(range(0, 10)) - hate_set, [int(str(ans)[i]) for i in range(len(str(ans)))])) and ans >= price:
return ans
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> |
s845038590 | p04045 | Runtime Error | price, len_hate_set = map(int, input().split())
hate_set = set([int(i) for i in input().split()])
ans = 0
while True:
if all(map(lambda x: int(x) in set(range(0, 10)) - hate_set,
[int(str(ans)[i]) for i in range(len(str(ans)))])) and ans >= price:
print ans
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> |
s200630963 | p04045 | Runtime Error | n, k = input().split()
dic = [int(_) for _ in input().split()]
not_in = [i for i in range(10) if i not in dic]
ans = [min(list(filter(lambda x: int(i) <= x, not_in))) for i in n]
print(''.join(map(str, 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> |
s614384793 | p04045 | Runtime Error | n, k = map(int, input().split())
d = [int(i) for i in input().split()]
for i in range(100000):
m = n + i
N = []
while(m > 0):
N.append(m%10)
m //= 10
N.reverse()
if N.intersection(d) == []:
print(N)
exit()
else:
continue | 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> |
s676841300 | p04045 | Runtime Error | #! /usr/bin/python3
# こだわり者いろはちゃん / Iroha's Obsession
"""
1≦N<10000
1≦K<10
0≦D1<D2<…<DK≦9
{D1,D2,…,DK}≠{1,2,3,4,5,6,7,8,9}
"""
N, K = map(int, input().split())
D = list(map(int, input().split()))
test_mode = False
def check_num(x, d):
"""
金額xの中に中の文字があるか確認する関数。
x : 現在の金額(N, x+1 を想定)
d : 嫌いな数字のリスト(D を想定)
文字列 x にリスト d 中の要素が含まれているか、d の要素 num を順に確認し、
含まれていたら1円足して再試行する。
"""
if test_mode:
print('x =', x)
for num in d:
str_x = str(x)
str_num = str(num)
if str_num in str_x:
return check_num(x+1, d)
return x
amount = check_num(N, D)
print(amount)
| 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> |
s784693491 | p04045 | Runtime Error | #! /usr/bin/python3
# こだわり者いろはちゃん / Iroha's Obsession
"""
1≦N<10000
1≦K<10
0≦D1<D2<…<DK≦9
{D1,D2,…,DK}≠{1,2,3,4,5,6,7,8,9}
"""
N, K = map(int, input().split())
D = list(map(int, input().split()))
test_mode = False
def check_num(x, d):
"""
金額xの中に中の文字があるか確認する関数。
x : 現在の金額(N, x+1 を想定)
d : 嫌いな数字のリスト(D を想定)
文字列 x にリスト d 中の要素が含まれているか、d の要素 num を順に確認し、
含まれていたら1円足して再試行する。
"""
if test_mode:
print('x =', x)
for num in d:
str_x = str(x)
str_num = str(num)
if str_num in str_x:
return check_num(x+1, d)
return x
def main():
"""
金額を算出して出力
"""
amount = check_num(N, D)
print(amount)
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> |
s608883540 | p04045 | Runtime Error | #! /usr/bin/python3
# こだわり者いろはちゃん / Iroha's Obsession
"""
1≦N<10000
1≦K<10
0≦D1<D2<…<DK≦9
{D1,D2,…,DK}≠{1,2,3,4,5,6,7,8,9}
"""
N, K = map(int, input().split())
D = list(map(int, input().split()))
test_mode = False
def check_num(x, d, n):
"""
金額xの中に中の文字があるか確認する関数。
x : 現在の金額(N, x+n を想定)
d : 嫌いな数字のリスト(D を想定)
n : 元の金額(N を想定)
文字列 x にリスト d 中の要素が含まれているか、d の要素 num を順に確認し、
含まれていたら元の金額 n を足して再試行する。
"""
if test_mode:
print('x =', x)
for num in d:
if test_mode:
print('num =', num)
str_x = str(x)
str_num = str(num)
if str_num in str_x:
return check_num(x+n, d, n)
return x
def main():
"""
金額を算出して出力
"""
amount = check_num(N, D, N)
print(amount)
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> |
s005737478 | p04045 | Runtime Error | iN,iK = [int(x) for x in input().split()]
aD = [int(x) for x in input().split()]
aUnList = sorted([x for x in range(10) if x not in aD])
aUnList.sort()
sN = str(iN)
iF = int(sN[0])
def fCheckDigit(sTarget,iPoint,aUnList,aRet,bRev):
iL = len(sTarget)
iF = int(sTarget[iPoint])
aUpper = [x for x in aUnList if x >= iF]
aUpper.sort()
if bRev: #遡ってきたとき
#もうひとつ上があるかどうか
if len(aUpper) == 1 and aUpper[0] == iF: #==のとき。もうひとつ上はない
if iPoint == 0:
if aUnList[0] == 0:
return [str(aUnList[1])] + ["0"] * iL
else:
return [str(aUnList[0])] * iL
else:
return fCheckDigit(sTarget,iPoint -1 , aUnList,aRet,True)
else: #上の桁がある
if len(aUpper) == 1:
iNext = aUpper[0]
else:
iNext = aUpper[1]
return aRet[0:iPoint]+[str(iNext)]+[str(aUnList[0])]*(iL-1-iPoint)
else: #順向
if aUpper == []: #大きい数字がない
if iPoint == 0:
if aUnList[0] == 0:
return [str(aUnList[1])] + ["0"] * iL
else:
return [str(aUnList[0])]*(iL+1)
else:
return fCheckDigit(sTarget,iPoint+1,aUnList,aRet,False)
else:
if aUpper[0] != iF:
return aRet[0:iPoint]+[str(aUpper[0])] + [str(aUnList[0])]*(iL-1- iPoint)
else:
aRet.append(str(iF))
if iPoint < iL -1 :
return fCheckDigit(sTarget,iPoint+1,aUnList,aRet,False)
else:
return aRet
print( ''.join(fCheckDigit(sN,0,aUnList,[],False)))
| 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> |
s610435366 | p04045 | Runtime Error | iN,iK = [int(x) for x in input().split()]
aD = [int(x) for x in input().split()]
aUnList = sorted([x for x in range(10) if x not in aD])
sN = str(iN)
iF = int(sN[0])
def fCheckDigit(sTarget,iPoint,aUnList,aRet,bRev):
iL = len(sTarget)
iF = int(sTarget[iPoint])
aUpper = [x for x in aUnList if x >= iF]
if bRev: #遡ってきたとき
#もうひとつ上があるかどうか
if len(aUpper) == 1 and aUpper[0] == iF: #==のとき。もうひとつ上はない
if iPoint == 0:
if aUnList[0] == 0:
return [str(aUnList[1])] + ["0"] * iL
else:
return [str(aUnList[0])] * iL
else:
return fCheckDigit(sTarget,iPoint -1 , aUnList,aRet,True)
else: #上の桁がある
if len(aUpper) == 1:
iNext = aUpper[0]
else:
iNext = aUpper[1]
return aRet[0:iPoint]+[str(iNext)]+[str(aUnList[0])]*(iL-1-iPoint)
else: #順向
if aUpper == []: #大きい数字がない
if iPoint == 0:
if aUnList[0] == 0:
return [str(aUnList[1])] + ["0"] * iL
else:
return [str(aUnList[0])]*(iL+1)
else:
return fCheckDigit(sTarget,iPoint-1,aUnList,aRet,False)
else:
if aUpper[0] != iF:
return aRet[0:iPoint]+[str(aUpper[0])] + [str(aUnList[0])]*(iL-1- iPoint)
else:
aRet.append(str(iF))
if iPoint < iL -1 :
return fCheckDigit(sTarget,iPoint+1,aUnList,aRet,False)
else:
return aRet
print( ''.join(fCheckDigit(sN,0,aUnList,[],False)))
| 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> |
s734378322 | p04045 | Runtime Error | iN,iK = [int(x) for x in input().split()]
aD = [int(x) for x in input().split()]
aUnList = sorted([x for x in range(10) if x not in aD])
sN = str(iN)
iF = int(sN[0])
def fCheckDigit(sTarget,iPoint,aUnList,aRet,bRev):
iL = len(sTarget)
iF = int(sTarget[iPoint])
aUpper = [x for x in aUnList if x >= iF]
if bRev: #遡ってきたとき
#もうひとつ上があるかどうか
if len(aUpper) == 1 and aUpper[0] == iF : #==のとき。もうひとつ上はない
if iPoint == 0:
if aUnList[0] == 0:
return [str(aUnList[1])] + ["0"] * iL
else:
return [str(aUnList[0])] * iL
else:
return fCheckDigit(sTarget,iPoint -1 , aUnList,aRet,True)
else: #上の桁がある
return aRet[0:iPoint]+[str(aUpper[1])]+[str(aUnList[0])]*(iL-1-iPoint)
else: #順向
if aUpper == []: #大きい数字がない
if iPoint == 0:
if aUnList[0] == 0:
return [str(aUnList[1])] + ["0"] * iL
else:
return [str(aUnList[0])]*(iL+1)
else:
return fCheckDigit(sTarget,iPoint-1,aUnList,aRet,False)
else:
if aUpper[0] != iF:
return aRet[0:iPoint]+[str(aUpper[0])] + [str(aUnList[0])]*(iL-1- iPoint)
else:
aRet.append(str(iF))
if iPoint < iL -1 :
return fCheckDigit(sTarget,iPoint+1,aUnList,aRet,False)
else:
return aRet
print( ''.join(fCheckDigit(sN,0,aUnList,[],False)))
| 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> |
s413056807 | p04045 | Runtime Error | N , K = map(int,input().split())
lst = []
for i in range(K):
lst.append(input())
start = N
while True:
for num in str(start):
if num in lst:
break
else:
break
start += 1
print(str(start)) | 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> |
s795237012 | p04045 | Runtime Error | xs, k = input().split()
k = int(k)
xs = [int(x) for x in list(xs)]
ds = set([int(d) for d in input().split()])
#print(ds)
ans = []
for x in xs:
if x not in ds:
ans.append(x)
else:
us = [ u for u in range(0,10) if u not in ds ]
#print(us)
x = sorted([ p for p in us if p > x ]).pop(0)
ans.append(x)
print(''.join(map(str,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> |
s756688424 | p04045 | Runtime Error | a,b = map(int,input().split())
c = input().split()
while 1:
f = 1
s = str(a)
for i in c:
if i in s: f = 0
if f : break
c += 1
print(c) | 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> |
s367454447 | p04045 | Runtime Error | a,b = map(int,input().split())
c = input().split()
while 1:
f = 1
s = str(c)
for i in c:
if i in s: f = 0
if f : break
c += 1
print(c) | 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> |
s733606161 | p04045 | Runtime Error | a,b = map(int,input().split())
c = input().split()
while 1:
f = 1
s = str(c)
for i in s:
if i in c: f = 0
if f : break
c += 1
print(c) | 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> |
s676600008 | p04045 | Runtime Error | a,b = map(int,input().split())
c = input().split()
while 1:
f = 1
s = str(c)
for i in c:
if i in c: f = 0
if f : break
c += 1
print(c) | 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> |
s922400907 | p04045 | Runtime Error | n, k = map(int, input().split(" "))
d = input().split(" ")
for i in range(len(str(n))+1):
if str(n)[~i] not in d:
continue
while str(n)[~i] in d:
n += 10**i
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> |
s994723791 | p04045 | Runtime Error | n, k = map(int, input().split(" "))
d = input().split(" ")
for i in range(len(str(n))+1):
if str(n)[~i] not in d:
break
while str(n)[~i] in d:
n += 10**i
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> |
s946355450 | p04045 | Runtime Error | n, k = map(int, input().split(" "))
d = input().split(" ")
for i in range(len(str(n))+1):
while str(n)[~i] in d:
n += 10**i
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> |
s764495372 | p04045 | Runtime Error | N, K = map(int, input().split())
ds = [int(d) for d in input().split()]
us = [ i for i in range(10) if i not in ds]
#print(us)
oo = [int(s) for s in str(N)]
o_u = {}
for o in oo:
o_u[o] = min(list(filter(lambda x:x>=o, us)))
n = str(N)
for o, u in o_u.items():
n = n.replace(str(o),str(u))
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> |
s067092316 | p04045 | Runtime Error | 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:
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> |
s812863341 | p04045 | Runtime Error | n, k = map(int,input().split())
n = str(n)
unlike = list(map(int,input().split()))
like = []
ans = ''
for i in range(1, 10):
if i not in unlike:
like.append(i)
for num in range(len(n)):
for i in like:
if n[0] == 9 and (9 not in like):
ans += like[0]
break
if int(n[num]) <= i:
ans += str(i)
break
if len(ans) != (num + 1):
for j in like:
if int(ans[num - 1]) < j:
ans[num - 1] == j
break
if num == 0:
like.insert(0,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> |
s612952511 | p04045 | Runtime Error | n, k = (int(char) for char in input().split())
d = [int(i) for i in input().split()]
'''
n = 10
k = 8
d = [0, 2, 3]
D = [i for i in range(10)]
'''
like_vals = [int(str(i)) for i in D if i not in d]
i = 0
n = [int(str(n)[i]) for i in range(len(str(n)))]
r = [-1] * len(n)
while i < len(n):
if n[i] in like_vals:
r[i] = n[i]
i += 1
elif n[i] < max(like_vals):
like_bigger = [like_val for like_val in like_vals if like_val > n[i]]
r[i] = min(like_bigger)
for j in range(i + 1, len(n)):
r[j] = min(like_vals)
break
else:
r = [-1] * (len(n) + 1)
if min(like_vals) != 0:
r[0] = min(like_vals)
else:
r[0] = min([like_val for like_val in like_vals if like_val != 0])
for j in range(1, len(n) + 1):
r[j] = min(like_vals)
break
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> |
s511819129 | p04045 | Runtime Error | 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:
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> |
s489127000 | p04045 | Runtime Error | 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)
return 0
| 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> |
s418004815 | p04045 | Runtime Error | def c_iroha_obsession(N, K, D):
for ans in range(N, 10 * N + 1):
for digit in str(ans): # 1桁ずつ調べる
if int(digit) in D: # 嫌いな数字があった
break
else: # 嫌いな数字がなかった。このときのansが解
break
return ans
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> |
s464018841 | p04045 | Runtime Error | 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
ans = []
apnd = ans.append
num, i = N, 0
while num > 0:
while num % 10 in D:
num += 1
top = i
num, m = divmod(num, 10)
apnd(m)
i += 1
ans[0:top] = [min_] * top
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> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.