submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s857317350
p04045
Runtime Error
# -*- coding : utf-8 -*- n,k = map(int, input().split()) D = list(map(str, input().split())) curr_num = N while True : n_str = str(curr_num) for d in D: if d in n_str: curr_num += 1 break else: print(curr_num) 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s080804357
p04045
Runtime Error
# -*- coding : utf-8 -*- n,k = map(int, input().split()) D = list(map(str, input().split())) while True : n_str = str(N) for d in D: if d in n_str: N += 1 break else: print(N) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s067811569
p04045
Runtime Error
n, k = map(int, input().split()) d = list(map(int, input().split())) other = [i for i in range(10)] - d m = 0 def dfs(m, now): m = int(m) if(m >= n): print(int(now)) else: if(m == 0): m = "" m = str(m) for(o in other): dfs(m, m + o)
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s925235212
p04045
Runtime Error
class A: def solve(self): [a, b, c] = sorted([int(x) for x in input().split(" ")]) if a == 5 and b == 5 and c == 7: print("YES") else: print("NO") class B: def solve(self): [n, l] = [int(x) for x in input().split(" ")] strings = [] for r in range(n): strings.append(input()) sorted_strings = sorted(strings) print("".join(sorted_strings)) class C: def solve(self): [n, k] = [int(x) for x in input().split(" ")] dislikes = [int(x) for x in input().split(" ")] likes = [] for r in range(10): if r not in dislikes: likes.append(r) import bisect as b final_amount = [] for c in str(n): i = b.bisect_left(likes, int(c)) final_amount.append(str(likes[i])) print("".join(final_amount)) C().solve()
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s303559524
p04045
Runtime Error
n,k=map(int, input().split()) ds=list(map(str, input().split())) while i in str(n) for i in ds: n+=1 print(str(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s213518475
p04045
Runtime Error
n,k=map(int, input().split()) ds=[] for i in range(len(k)): ds.append(input()) ans=n while ds in ans: ans+=1 print(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s927887613
p04045
Runtime Error
n , k = map(int,input().split()) d = set(list(map(int,input().split()))) kouho =list({0,1,2,3,4,5,6,7,8,9} - d) kouho.sort() def f(now): if now >= n: print(now) exit() for i in kouho: f(now*10 + i) f(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s978087471
p04045
Runtime Error
n,k = map(int,input().split()) #入力 a = list(map(int,input().split())) #使用不可の数字 b = {0,1,2,3,4,5,6,7,8,9}-set(a) #使用可能な数字の集合 n = [int(i) for i in list(str(n))] #価格(int)をリストに分解 while set([int(i) for i in list(str(n))])-b !={} : # 使用可能な数字のみでなければ 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s423622729
p04045
Runtime Error
n,k = map(int,input().split()) #入力 a = list(map(int,input().split())) #使用不可の数字 n2 = [int(i) for i in list(str(n))] #価格を分解 for i in n2: while n2[i] in a :#使用不可ならば n2[i] += 1 if n2[i]>=10: n2[i] =1 print("".join([str(i) for i in n2]))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s208962859
p04045
Runtime Error
n,k = map(int,input().split()) #入力 a = list(map(int,input().split())) #使用不可の数字 b = list({0,1,2,3,4,5,6,7,8,9}-set(a)) #使用可能な数字のリスト n2 = [int(i) for i in list(str(n))] #価格を分解 for i in n2: while n2[i] in a :#使用不可ならば n2[i] += 1 print("".join([str(i) for i in n2]))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s818556852
p04045
Runtime Error
N,K= map(int,input().split()) D = [int(j) for j in input().split()] D2 = list(set([i for i in range(0,10)])-set(D)) D1 = list(set([i for i in range(1,10)])-set(D)) ans ='' for i in reversed(range(-len(str(N)),0)): if int(str(N)[i]) not in D: ans+=str(N)[i] elif i==-len(str(N)): ans+=str(min(D1)) else: ans+=str(min([d for d in D2 if d>int(str(N)[i])])) print(int(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s411723615
p04045
Runtime Error
#input #n=3519,k=5,d=0,2,5,7,9 d0=[0,1,2,3,4,5,6,7,8,9] n,k=map(int,input().split()) d=list(map(int,input().split())) for i in range(k):d0.remove(d[i]) n=str(n) n=n[::-1] ans0=0 for i in range(len(n)): for j in range(len(d0)): if int(n[i])==9 and i<(len(n)-1) and d0[len(d0)-1]!=9: ans=10**i * d0[0] break elif int(n[i])==9 and i==(len(n)-1) and d0[len(d0)-1]!=9: ans=10**(i+1) * d0[0] + 10**i * d0[0] break elif int(n[i])==d0[j]: ans=10**(i) * d0[j] break elif int(n[i])<d0[j]: ans=10**(i) * d0[j] break ans0=ans0+ans print(ans0)
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s568847651
p04045
Runtime Error
from collections import deque n, k = map(int, input().split()) D = list(map(int, input().split())) # 1. 初期化 ok_lst = [x for x in range(0, 10) if x not in D] ok_lst.sort(reverse = True) stack = deque([x for x in ok_lst if x != 0]) while len(stack) > 0: # 2. 現在の情報の取得 # 今回は現在の数字 now_num = stack.pop() # 3. 処理 # もしnow_numの桁数がnの桁数と同じかつ条件の値以上の場合,ansに記録しwhileを終了. # もしnow_numの桁数がnの桁数と同じかつ条件の値未満の場合,次は数値を足すとまずいのでcontinueで防ぐ if len(str(now_num)) == len(str(n)) and now_num >= n: ans = now_num break if len(str(now_num)) == len(str(n)) and now_num < n: continue # 4. 更新 for x in ok_lst: next_num = str(now_num) + str(x) next_num = int(next_num) stack.append(next_num) 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s187741334
p04045
Runtime Error
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(str, input().split())) def ZIP(n): return zip(*(MAP() for _ in range(n))) import numpy as np sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 """ lim = 2*10**5 #必要そうな階乗の限界を入力 #階乗# fact = [1] * (lim+1) for n in range(1, lim+1): fact[n] = n * fact[n-1] % mod #階乗の逆元# fact_inv = [1]*(lim+1) fact_inv[lim] = pow(fact[lim], mod-2, mod) for n in range(lim, 0, -1): fact_inv[n-1] = n*fact_inv[n]%mod def C(n, r): return (fact[n]*fact_inv[r]%mod)*fact_inv[n-r]%mod """ N, K = MAP() D = LIST() while 1: if set(list(str(N))) & set(D) == set(): print(N) break N += 1
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s120190106
p04045
Runtime Error
import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections MOD = 10**9+7 MAX = 10**18 MIN = -10**18 n,k= map(int,input().split()) d = list(map(int,input().split())) able = [True]*10 for i in range(k): able[d[i]] = False use = [] for i in range(len(able)): if able[i] == True: use.append(i) while True: ans = "" s = str(n) for i in range(len(s)): c = int(s[i]) for j in range(len(use)): if c<=use[j]: ans += str(use[j]) break if int(ans)>=n: break else: 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s074580474
p04045
Runtime Error
inputNK = input() N = int(inputNK[0]) K = int(inputNK[1]) dislike = input.split(" ") judge = true answer = 0 for i in range(N,INF): for number in dislike: if str(i).count(number) != 0 judge = false break if judge == true: answer = i break else: judge = true print(i)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s831259203
p04045
Runtime Error
import itertools NK = input().split() N = NK[0] K = int(NK[1]) d = input().split() D = [int[s] for s in d] Da = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] for i in D: Da.remove(i) Da_str = [str(j) for j in Da] a_1 = [''.join(j) for j in itertools.product(Da_str, repeat=len(N))] a_2 = [''.join(j) for j in itertools.product(Da_str, repeat=len(N)+1)] a = a_1 + a_2 nu = [int(k) for k in a] for i in nu: if i >= int(N): print(i) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s683703784
p04045
Runtime Error
import itertools NK = input().split() N = NK[0] K = int(NK[1]) d = input().split() D = [int[s] for s in d] Da = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] for i in D: Da.remove(i) Da_str = [str(j) for j in Da] a_1 = [''.join(j) for j in itertools.product(Da_str, repeat=len(N))] a_2 = [''.join(j) for j in itertools.product(Da_str, repeat=len(N)+1)] a = a_1 + a_2 nu = [int(k) for k in a] for i in nu: if i >= int(N): print(i) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s407099380
p04045
Runtime Error
import itertools NK = input().split() N = NK[0] K = int(NK[1]) d = input().split() D = [int[s] for s in d] Da = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] for i in range(len(D)): Da.remove(D[i]) Da_str = [str(j) for j in Da] a_1 = [''.join(j) for j in itertools.product(b_st, repeat=len(N))] a_2 = [''.join(j) for j in itertools.product(b_st, repeat=len(N)+1)] a = a_1 + a_2 nu = [int(k) for k in a] for i in nu: if i >= int(N): print(i) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s681043206
p04045
Runtime Error
import itertools NK = input().split() N = NK[0] K = int(NK[1]) d = input().split() D = [int[s] for s in d] Da = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] for i in range(len(D)): Da.remove(D[i]) Da_str = [str(j) for j in Da] a_1 = [''.join(j) for j in itertools.product(b_st, repeat=len(N))] a_2 = [''.join(j) for j in itertools.product(b_st, repeat=len(N)+1)] a = a_1 + a_2 nu = [int(k) for k in a] for i in nu: if i >= N: print(i) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s060859799
p04045
Runtime Error
import itertools NK = input().split() N = NK[0] K = int(NK[1]) d = input().split() D = [int[s] for s in d] Da = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] for i in range(len(D)): Da.remove(D[i]) nu = [] for j in itertools.combinations_with_replacement(Da, len(N)+1): b = ''.join([str(j[i]) for i in range(len(N)+1)]) nu.append(int(b)) for i in nu: if i >= N: print(i) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s656527362
p04045
Runtime Error
import copy def make1d(n, m): return [copy.deepcopy(m) for i in range(0,n)] s = list(map(int, input().split())) t = list(map(int, input().split())) #支払う金額s[0]を桁ごとに分解する #支払う金額の桁数:n n = 0 while (s[0] // (10 ** n)) >= 10: n = n + 1 l = make1d(n + 1, 1) m = s[0] for i in range(0, n + 1): l[n - i] = m % 10 m = m // 10 #使えない数字->tを使える数字->numに変換 num = make1d(10, 1) for i in range(0, len(t)): num[t[i]] = 0 #支払う金額からスタートしてダメな数字を含む場合は1増やしていく #払うべき金額->l,使える数字->num(使える->1,使えない->0),支払う金額(答え)->a a = l limit = 10 ** len(a) - 1 a_int = int(''.join(map(str, a))) #桁数が一致しているときは tmp = 1 for i in range(0, n + 1): tmp = tmp * num[a[i]] if tmp == 1: ans = a_int while tmp == 0: if(a_int <= limit - 1): a_int = a_int + 1 a_tmp = a_int for i in range(0, n + 1): a[n - i] = a_tmp % 10 a_tmp = a_tmp // 10 tmp = 1 for i in range(0, n + 1): tmp = tmp * num[a[i]] ans = a_int else:#桁が一つ増える場合 count = 0 count_n = 1#0以外の最小の数 while count == 0: count = count + num[count_n] if num[0] == 1: a = make1d[n + 2, 0] a[0] = count_n else: a = make1d[n + 2, count_n] ans = int(''.join(map(str, a))) 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s026985626
p04045
Runtime Error
N, K = map(int, input().split()) D = list(map(int, input().split())) OK = list({1, 2, 3, 4, 5, 6, 7, 8, 9} - set(D)) S = str(N) ans = [] def find_next(x): while True: x += 1 if x in OK: return str(x) for i in range(len(S)): if int(S[i]) in OK: ans += S[i] elif max(OK) > int(S[0]): ans += find_next(int(S[0])) for _ in range(len(S) - len(ans)): ans += "0" break else: if i == 0: ans += str(min(OK)) else: ans[-1] = find_next(ans[-1]) for _ in range(len(S) - len(ans) + 1): ans += "0" break print("".join(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s101671575
p04045
Runtime Error
n, k = map(int,input().split()) d = list(map(int,input().split())) s = 0 while s == d[s]: s += 1 x = 0 y = 0 while x <4: if n // (10**x) >0: y = x x += 1 i = 0 a = [0] m = 0 while i <= y: a.append(((n//(10**(y-i)))%10)) i +=1 i = 0 t = 0 while i <= y + t: j = 0 while j < k: if a[y-i+1] == d[j]: a[y-i+1] += 1 if y-i+1 < y+1: a[y-i+2] = s if a[y-i+1] == 10: a[y-i+1] = 0 a[y-i] +=1 j+=1 i+=1 if a[0] == 1 and t == 0: i = 1 while i<=y+1: a[i] = 0 i += 1 i = 0 t = 1 continue i = 0 while i <= y + t: m += a[y-i+1]*(10**(i)) i+=1 print(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s519971500
p04045
Runtime Error
n, k = map(int,input().split()) d = list(map(int,input().split())) x = 0 y = 0 while x <4: if n // (10**x) >0: y = x x += 1 i = 0 a = [0] m = 0 while i <= y: a.append(((n//(10**(y-i)))%10)) i +=1 i = 0 t = 0 while i <= y + t: j = 0 while j < k: if a[y-i+1] == d[j]: a[y-i+1] += 1 if a[y-i+1] == 10: a[y-i+1] = 0 a[y-i] +=1 j+=1 i+=1 if a[0] == 1 and t == 0: a[1] = 0 a[2] = 0 a[3] = 0 a[4] = 0 i = 0 t = 1 continue i = 0 while i <= y + t: m += a[y-i+1]*(10**(i)) i+=1 print(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s399996043
p04045
Runtime Error
n, k = map(int,input().split()) d = list(map(int,input().split())) x = 0 y = 0 while x <4: if n // (10**x) >0: y = x x += 1 i = 0 a = [0] m = 0 while i <= y: a.append(((n//(10**(y-i)))%10)) i +=1 i = 0 t = 0 while i <= y + t: j = 0 while j < k: if a[y-i+1] == d[j]: a[y-i+1] += 1 if a[y-i+1] == 10: a[y-i+1] = 0 a[y-i] +=1 j+=1 i+=1 if a[0] == 1 and t == 0: a[1] = 0 a[2] = 0 a[3] = 0 a[4] = 0 i = 0 t = 1 continue i = 0 while i <= y + 1: m += a[y-i+1]*(10**(i)) i+=1 print(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s336074556
p04045
Runtime Error
n, k = map(int,input().split()) d = list(map(int,input().split())) x = 0 y = 0 while x <4: if n // (10**x) >0: y = x x += 1 i = 0 a = [0] m = 0 while i <= y: a.append(((n//(10**(y-i)))%10)) i +=1 i = 0 t = 0 while i <= y: j = 0 while j < k: if a[y-i+1] == d[j]: a[y-i+1] += 1 if a[y-i+1] == 10: a[y-i+1] = 0 a[y-i] +=1 j+=1 i+=1 if a[0] == 1 and t == 0: a[1] = 0 a[2] = 0 a[3] = 0 a[4] = 0 i = 0 t = 1 continue i = 0 while i <= y + 1: m += a[y-i+1]*(10**(i)) i+=1 print(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s621917806
p04045
Runtime Error
n, k = map(int,input().split()) d = list(map(int,input().split())) x = 0 y = 0 while x <4: if n // (10**x) >0: y = x x += 1 i = 0 a = [0] m = 0 while i <= y: a.append(((n//(10**(y-i)))%10)) i +=1 i = 0 t = 0 while i <= y: j = 0 while j < k: if a[y-i+1] == d[j]: a[y-i+1] += 1 if a[y-i+1] == 10: a[y-i+1] = 0 a[y-i] +=1 j+=1 i+=1 if a[0] == 1 and t == 0: a[1] = a[2] = a[3] = a[4] = i = 0 t = 1 continue i = 0 while i <= y + 1: m += a[y-i+1]*(10**(i)) i+=1
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s154583960
p04045
Runtime Error
n, k = map(int,input().split()) d = list(map(int,input().split())) x = 0 y = 0 while x <4: if n // (10**x) >0: y = x x += 1 i = 0 a = [0] m = 0 while i <= y: a.append(((n//(10**(y-i)))%10)) i +=1 i = 0 while i <= y: j = 0 while j < k: if a[y-i+1] == d[j]: a[y-i+1] += 1 if a[y-i+1] == 10: a[y-i+1] = 0 a[y-i] +=1 j+=1 i+=1 if a[0] == 1: a[1] = a[2] = a[3] = a[4] = i = 0 continue i = 0 while i <= y + 1: m += a[y-i+1]*(10**(i)) i+=1 print(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s659250155
p04045
Runtime Error
n,k=list(map(int,input().split())) D=list(map(int,input().split())) like=[] for i in range(10): if not i in D: like.append(i) N=str(n) ans=[] for i in range(len(N)): for j in range(len(like)): if like[j]>=int(N[i]): ans.append(like[j]) break else: if not like[0]==0: ans.append(like[1]) else: ans.append(like[0]) for i in range(len(N)): ans.append(like[0]) break if ans[i]>int(N[i]): for i in range(i+1,len(N)): ans.append(like[0]) break answer=''.join(map(str,ans)) print(int(answer))
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s031267728
p04045
Runtime Error
import itertools def solve(n, k, xs): tmp = [str(i) for i in range(10) if i not in xs] str_len = len(str(n)) hoge = [i for i in map(lambda x: int("".join(x)), itertools.product(tmp, repeat=str_len)) if i >= n] return hoge[0] if __name__ == "__main__": n, k = [int(i) for i in input().split()] xs = [int(i) for i in input().split()] print(solve(n, k, xs))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s775029378
p04045
Runtime Error
import math n,k = list(map(int, input().split())) a = list(map(int, input().split())) for ii in range(n*10): i = ii+1 ar = ValueToArray10(i, int(1+(math.log(i)+0.00001)/math.log(10))) ok=1 for j in ar: for k in a: if(j==k): ok=0 if(ok==1 and i>=n): print(i) exit()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s817785256
p04045
Runtime Error
l=list(map(int,input().split())) d=list(map(int,input().split())) d_bar=[] for m in range(10): if m not in d: d_bar.append(m) d_bar.sort() n=[int(k) for k in str(l[0]) for i in range(len(n)) dig1=0 dig2=0 for j in range(l[1]): p=dig1+d_bar[j]*10**(range(l[0])-i) if p>l[0]: break dig1=p dig2=dig2+d_bar[j]*l[1]**(range(l[0])-i) dig2=dig2+1 r=dig R=[] while q!=0 or q!=1: q=q/l[1] r=q%l[1] R.append(r) s=int(sum[str(-t-1) for t in R]) 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s669673608
p04045
Runtime Error
l=list(map(int,input().split())) d=list(map(int,input().split())) d_bar=[] for m in range(10): if m not in d: d_bar.append(m) d_bar.sort() a=[] p=0 n_int=[int(k) for k in str(l[0])] for i in range(len(n_int)): a.append(10) for j in range(len(d_bar)): if n_int[-i-1]==d_bar[j]: a.pop(i) a.append(d_bar[j+p]) p=0 break elif n_int[-i-1]<d_bar[j]: a.pop(i) a.append(d_bar[j]) p=0 break if a[i]==10: a.pop(i) a.append(d_bar[0]) p=1 b='' for q in range(len(n_int)): b=b+str(a[-q-1]) 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s895417764
p04045
Runtime Error
l=list(map(int,input().split())) d=list(map(int,input().split())) d_bar=[] for m in range(10): if m not in d: d_bar.append(m) d_bar.sort() a=[] n_str=str(l[0]) n_int=[int(k) for k in n_str] for i in n_int: a.append('na') for j in d_bar: if i<=j: a[i-1]=j break else: pass if a[i-1]='na': a[i-1]=d_bar[0] if a[0]=0: a.insert(0,d_bar[0]) print(int(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s209511472
p04045
Runtime Error
l=list(map(int,input().split())) d=list(map(int,input().split())) d_bar=[] for m in range(10): if m not in d: d_bar.append(m) d_bar.sort() a='' for i in str(l[0]): for j in d_bar: if int(i)<=j: k=str(j) break else: pass a=a+k print(int(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s523848461
p04045
Runtime Error
n, k = map( int, input().split()) hate = set( input().split()) usable = sorted( list( {str(i) for i in range(10)} - hate)) l = len(str(n)) def check(l): num = [] if l == 1: for i in usable: num.append(i) if l == 2: for ii in usable: for i in usable: num.append(int( str(ii) + str(i))) elif l == 3: for iii in usable: for ii in usable: for i in usable: num.append(int( str(iii) + str(ii) + str(i))) elif l == 4: for iv in usable: for iii in usable: for ii in usable: for i in usable: num.append(int( str(iv) + str(iii) + str(ii) + str(i))) else: for v in usable: for iv in usable: for iii in usable: for ii in usable: for i in usable: num.append(int( str(v) + str(iv) + str(iii) + str(ii) + str(i))) return num truf = False num = check(l) for i in num: if n <= i: print(i) truf = True break if not truf: num = check(l+1) for i in num: if n <= i: print(i) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s771393223
p04045
Runtime Error
n, k = map( int, input().split()) hate = set( input().split()) usable = sorted( list( {str(i) for i in range(10)} - hate)) l = len(str(n)) def check(l): num = [] if l == 1: for i in usable: num.append(i) if l == 2: for ii in usable: for i in usable: num.append(int( str(ii) + str(i))) elif l == 3: for iii in usable: for ii in usable: for i in usable: num.append(int( str(iii) + str(ii) + str(i))) elif l == 4: for iv in usable: for iii in usable: for ii in usable: for i in usable: num.append(int( str(iv) + str(iii) + str(ii) + str(i))) else: for v in usable: for iv in usable: for iii in usable: for ii in usable: for i in usable: num.append(int( str(v) + str(iv) + str(iii) + str(ii) + str(i))) return num truf = False num = check(l) for i in num: if n <= i: print(i) truf = True break if not truf: num = check(l+1) for i in num: if n <= i: print(i)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s472313769
p04045
Runtime Error
a,n=map(int,input()) b=[] for i in range(n): b.append(int(input()) flag="F" which flag=="F": k=a fflag="T" which k>=1 and fflag=="T": l=int(k%10) for i in range(n): if a[i]==l: fflag="F" break if fflag=="T": flag="T" else: a+=1 print(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s305178661
p04045
Runtime Error
N, L = map(int, input().split()) hates = [input() for _ in range(N)] for i in range(N, 9999): nums = list(str(i)) com = set(nums) & set(hates) if len(com) == 0: print(i)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s203917040
p04045
Runtime Error
import sys N,K = map(int, input().split()) *D, = input().split() for n in range(N, 10000, 1): L = list(str(n)) flg = 0 for l in L: if (l in D) or n<N: flg = 1 break if flg==0: print(n) sys.exit(9)
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s553242666
p04045
Runtime Error
N,K=map(int,input().split()) D=list(map(int,input().split())) for price in range(N,10**4+1): s=str(price) flag=True for i in range(len(s)): if int(s[i]) in D: flag=False if flag: ans=price 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s618811671
p04045
Runtime Error
n,k = map(int,input().split()) d = list(input().split()) ans = n while True: flag = False for i in d: if flag :break if i in str(ans): x = len(str(n)) - str(n).index(i) - 1 ans += 10**x flag = True if flag:continue print(ans) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s151171527
p04045
Runtime Error
n,k = map(int,input().split()) d = list(input().split()) ans = n while True: flag = False for i in d: if flag :break if i in str(ans): x = len(str(n)) - str(n).index(i) - 1 ans += 10**x flag = True if flag:continue print(ans) exit(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s568916532
p04045
Runtime Error
N, K = map(str, input().split()) N = ''.join(list(reversed(N))) num_ls = [i for i in range(10)] ls = map(int, input().split()) dif = list(set(num_ls) - set(ls)) dif.sort() ans = '' for i in N: tmp = min(filter(lambda x: int(i) <= x, dif)) if tmp == None: tmp=min(dif) ans = ans + str(tmp) print(''.join(list(reversed(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s140604602
p04045
Runtime Error
def function(m, set1): set2 = set(str(m)) if len(set1 & set2) > 0: return False else: return True def function(n, set1): m = n while not function(m, set1): m += 1 return m line1 = input().split() n = int(line1[0]) k = int(line1[1]) list1 = [] for i in range(k): list1.append(int(input())) set1 = set(list1) print(function(n, set1))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s503285288
p04045
Runtime Error
N, K = map(int, input().split()) D = list(map(int, input(split()))) i = N while True: flg = True for j in str(i): if int(j) in D: flg = False break if flg == True: print(i) exit() i += 1
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s980819994
p04045
Runtime Error
import numpy as np import sys import math readline = sys.stdin.buffer.readline #N,K = map(int, readline().split()) N = list(input()) #print(N) K=int(N[len(N)-1]) N.remove(' ') N.remove(N[len(N)-1]) #print(N) A = list(input().split()) #print(N,K) #print(A) Number=['1','2' ,'3', '4', '5', '6', '7', '8', '9','0'] #''' for i in range(0,K): if A[i]== '1': Number.remove('1') elif A[i]== '2': Number.remove('2') elif A[i]== '3': Number.remove('3') elif A[i]== '4': Number.remove('4') elif A[i]== '5': Number.remove('5') elif A[i]== '6': Number.remove('6') elif A[i]== '7': Number.remove('7') elif A[i]== '8': Number.remove('8') elif A[i]== '9': Number.remove('9') elif A[i]== '0': Number.remove('0') #''' #print(N,K) #print(A) #print(Number,'Number') Answer=[] #print(N,'N') for i in range(0,len(Number)): for j in range (0,len(N)): if int(Number[i])>=int(N[j]): Answer.append(Number[i]) #print(min(Number[i])) Answer1=[] for i in range (0,len(N)): Answer1.append(Answer[i]) #Answer1.reverse() Answer1 = ''.join(Answer1) print(Answer1)
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s775708733
p04045
Runtime Error
import numpy as np import sys import math readline = sys.stdin.buffer.readline #N,K = map(int, readline().split()) N = list(input()) #print(N) K=int(N[len(N)-1]) N.remove(' ') N.remove(N[len(N)-1]) #print(N) A = list(input().split()) #print(N,K) #print(A) Number=['1','2' ,'3', '4', '5', '6', '7', '8', '9','0'] #''' for i in range(0,K): if A[i]== '1': Number.remove('1') elif A[i]== '2': Number.remove('2') elif A[i]== '3': Number.remove('3') elif A[i]== '4': Number.remove('4') elif A[i]== '5': Number.remove('5') elif A[i]== '6': Number.remove('6') elif A[i]== '7': Number.remove('7') elif A[i]== '8': Number.remove('8') elif A[i]== '9': Number.remove('9') elif A[i]== '0': Number.remove('0') #''' #print(N,K) #print(A) #print(Number,'Number') Answer=[] print(N,'N') for i in range(0,len(Number)): for j in range (0,len(N)): if int(Number[i])>=int(N[j]): Answer.append(Number[i]) #print(min(Number[i])) Answer1=[] for i in range (0,len(N)): Answer1.append(Answer[i]) #Answer1.reverse() Answer1 = ''.join(Answer1) print(Answer1)
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s236855492
p04045
Runtime Error
import numpy as np import sys import math readline = sys.stdin.buffer.readline #N,K = map(int, readline().split()) N = list(input()) #print(N) K=int(N[len(N)-1]) N.remove(' ') N.remove(N[len(N)-1]) #print(N) A = list(input().split()) #print(N,K) #print(A) Number=['1','2' ,'3', '4', '5', '6', '7', '8', '9','0'] #''' for i in range(0,K): if A[i]== '1': Number.remove('1') elif A[i]== '2': Number.remove('2') elif A[i]== '3': Number.remove('3') elif A[i]== '4': Number.remove('4') elif A[i]== '5': Number.remove('5') elif A[i]== '6': Number.remove('6') elif A[i]== '7': Number.remove('7') elif A[i]== '8': Number.remove('8') elif A[i]== '9': Number.remove('9') elif A[i]== '0': Number.remove('0') #''' #print(N,K) #print(A) #print(Number,'Number') Answer=[] for i in range(0,len(Number)): for j in range (0,len(N)): if int(Number[i])>=int(N[j]): Answer.append(min(Number[i])) #print(min(Number[i])) #print(N,'N') Answer1=[] for i in range (-len(N),0): Answer1.append(Answer[i]) Answer1 = ''.join(Answer1) print(Answer1)
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s589137447
p04045
Runtime Error
N, K = map(int, input().split()) num = ["0","1","2","3","4","5","6","7","8","9"] dis = input().split() can_use = sorted(list(set(num)-set(dis))) sN = str(N) L = len(sN) ans = "" for i in range(1,L): if sN[i] in can_use: ans += sN[i] else: ans += min(can_use) if sN[0] in can_use: ans += sN[0] else: if can_use[0] == "0": ans = can_use[1] + ans else: ans = can_use[0] + ans if int(ans) < N: if can_use[0] != "0": ans = ans + can_use[1] else: ans = ans + can_use[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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s475720564
p04045
Runtime Error
N, K = map(int, input().split()) num = ["0","1","2","3","4","5","6","7","8","9"] dis = input().split() can_use = sorted(list(set(num)-set(dis))) sN = str(N) L = len(sN) ans = "" if sN[0] in can_use: ans += sN[0] else: if can_use[0] == "0": ans += can_use[1] else: ans += can_use[0] for i in range(1,L): if sN[i] in can_use: ans += sN[i] else: ans += min(can_use) if int(ans) < N: if can_use[0] != "0": ans = ans + can_use[1] else: ans = ans + can_use[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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s988366733
p04045
Runtime Error
n,k=map(int, input().split()) d=list(map(int, input().split())) l=list() for i in range(10): l.append(i) l=list(set(d) ^ set(l)) lFirst=list(set(l) ^ set([0])) nList=list(map(int, list(str(n)))) answer=list() flag=False for i in lFirst: if nList[0]<i: answer.append(i) for i in range(1,len(nList)): answer.append(l[0]) flag=True elif nList[0]==i: answer.append(i) break if False==flag: for i in range(1,len(nList)): for j in l: if nList[i]<=j: answer.append(j) break ans='' for i in answer: ans+=str(i) 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s013239175
p04045
Runtime Error
n, k = map(int, input().split()) d = list(map(int, input().split())) n_str = str(n) # print(n_str) l = list(({0, 1, 2, 3, 4, 5, 6, 7, 8, 9} - set(d))) # print(l) ans_list = [] for i in range(len(n_str)): if int(n_str[i]) in l: ans_list.append(n_str[i]) elif int(n_str[i]) < l[-1]: for j in range(len(l)): if l[j] > int(n_str[i]): ans_list.append(l[j]) break for k in range(i+1, len(n_str)): ans_list.append(l[0]) break # print(ans_list) ans = '' for i in range(len(ans_list)): ans += str(ans_list[i]) 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s675907851
p04045
Runtime Error
n,_=map(int,input().split()) s=set(input()) while s&set(str(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s774757704
p04045
Runtime Error
N = int(input().split(' ')[0]) D = set(input()) while len(set(str(N))&D)!=0: 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s816462613
p04045
Runtime Error
N, K = map(int, input().split()) D = list(map(int, input().split())) for ans = "" for n in str(N): a = 0 while True: if int(n) in D: n = int(n) + 1 a = int(n)+1 else: a = int(n) ans += str(a) 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s333019644
p04045
Runtime Error
N, K = map(int, input().split()) L = set(map(int, input().split())) A = set(i for i in range(10)) B = sorted(list(A - L)) N_digit = len(str(N)) pay = "" for i in str(N): for b in B: if b >= int(i): pay += str(b) break else: continue if int(pay): print(int(pay)) else: if int(min(B)) == 0: C = B - set(0) pay = str(min(C)) for i in range(digit_N): pay += "0" print(int(pay)) else: pay = str(min(C)) for i in range(digt_N): pay += str(min(C)) print(int(pay))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s720973416
p04045
Runtime Error
N, K = map(int, input().split()) L = set(map(int, input().split())) A = set(i for i in range(10)) B = sorted(list(A - L)) N_digit = len(str(N)) pay = "" for i in str(N): for b in B: if b >= int(i): pay += str(b) break else: continue print(int(pay))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s405076939
p04045
Runtime Error
N, K = map(int, input().split()) # L = set(input() for i in range(K)) L = set(map(int, input().split())) # 差集合→list A = set(i for i in range(10)) B = sorted(list(A - L)) N_digit = len(str(N)) pay = "" for i in str(N): for b in B: if b >= int(i): pay += str(b) break else: continue print(int(pay))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s538710672
p04045
Runtime Error
n,k=map(int,input().split()) d=list(map(int,input().split())) N=list(str(n)) for i in range(len(N)): N[i]=int(N[i]) for i in range(n,n*10+1): if not N.isdisjoint(d): print(i) exit()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s663589511
p04045
Runtime Error
N,K = map(int, input().split()) Ds = list(map(int, input().split())) able = [] for i in range(10): if i in Ds:continue able.append(i) # print(able) sN = str(N) n = len(sN) m = able[0] #最小 if int(sN[0]) > max(able): if m == 0: ans = str(able[1]) + str(able[0]) * n else: ans = str(able[0]) * (n+1) print(ans) exit() prev = -1 flg = True #確定していない ans = "" for i,s in enumerate(sN): flg2 = False if flg: for j,a in enumerate(able): if int(s) < a: ans += str(a) flg = False flg2 = True break if int(s) == a: ans += str(a) flg = True flg2 = True break if not flg2: ans = ans[:-1] ans += str(able[prev+1]) + str(m) flg = False else: ans += str(m) prev = j # print(ans) print(ans) """ 1333 8 0 3 4 5 6 7 8 9 """
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s127683617
p04045
Runtime Error
N,K = map(int, input().split()) Ds = list(map(int, input().split())) able = [] for i in range(10): if i in Ds:continue able.append(i) # print(able) sN = str(N) n = len(sN) m = able[0] #最小 if int(sN[0]) > max(able): if m == 0: ans = str(able[1]) + str(able[0]) * n else: ans = str(able[0]) * (n+1) print(ans) exit() prev = -1 flg = True #確定していない ans = "" for i,s in enumerate(sN): flg2 = False if flg: for j,a in enumerate(able): if int(s) < a: ans += str(a) flg = False flg2 = True break if int(s) == a: ans += str(a) flg = True flg2 = True break if not flg2: ans = ans[:-1] ans += str(able[prev+1]) + str(m) flg = True else: ans += str(m) prev = j print(ans)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s705312520
p04045
Runtime Error
N,K = list(map(str, input().split())) D = sorted(input().split()) W = [] P = "" for i in range(10): if str(i) not in D: W.append(str(i)) for i in range(len(N)): for j in range(len(W)): if N[i] <= W[j]: P += W[j] break print(int(P))
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s923943146
p04045
Runtime Error
n, k = input().split() d = input().split() valid = [i for i in range(10) if str(i) not in d] ans = '' if valid[-1] < int(n[0]): if valid[0] == 0: ans += str(valid[1]) else: ans += str(valid[0]) ans += str(valid[0]) * len(n) else: for i, s in enumerate(n): if i > 0 and ans[i-1] > n[i-1]: ans += str(valid[0]) * (len(n)-i) break for k in valid: if k >= int(s): ans += str(k) 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s929763507
p04045
Runtime Error
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s325231315
p04045
Runtime Error
import sys sys.setrecursionlimit(10**6) n_price,k = map(str,input().split()) k = int(k) n_length = len(n_price) d_ng_list = list(input()) restrict = True answer = "" for s in range(10): if str(s) not in d_ng_list: min_number = str(s) break def find_number(i): global restrict if not restrict: return min_number for s in range(10): if (str(s) not in d_ng_list) and str(s) >= n_price[i]: if s > int(n_price[i]): restrict = False return str(s) def rec_cal_pay(answer, i, restrict): if i == n_length-1: answer += find_number(i) print(answer) return else: c = find_number(i) rec_cal_pay(answer+c, i+1, restrict) rec_cal_pay(answer, 0, restrict)
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s330217009
p04045
Runtime Error
import sys sys.setrecursionlimit(10**6) n_price,k = map(str,input().split()) k = int(k) n_length = len(n_price) d_ng_list = list(map(str,input().split())) restricted = True answer = "" for s in range(10): if str(s) not in d_ng_list: min_number = str(s) break def find_number(i,restricted): if not restricted: return min_number for s in range(10): if str(s) not in d_ng_list and str(s) >= n_price[i]: if str(s) > n_price[i]: restricted = False return str(s) def rec_cal_pay(answer, i): if i == n_length-1: answer += find_number(i,restricted) print(answer) return else: c = find_number(i,restricted) rec_cal_pay(answer+c,i+1) rec_cal_pay(answer, 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s415705379
p04045
Runtime Error
n_price,k = map(str,input().split()) k = int(k) n_length = len(n_price) d_ng_list = list(map(str,input().split())) restricted = True answer = "" for s in range(10): if str(s) not in d_ng_list: min_number = str(s) break def find_number(i,restricted): if not restricted: return min_number for s in range(10): if str(s) not in d_ng_list and str(s) >= n_price[i]: if str(s) > n_price[i]: restricted = False return str(s) def rec_cal_pay(answer, i): if i == n_length-1: answer += find_number(i,restricted) print(answer) return else: c = find_number(i,restricted) rec_cal_pay(answer+c,i+1) rec_cal_pay(answer, 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s074367606
p04045
Runtime Error
n,k = map(int,input().split()) D = list(map(int,input().split())) while True: dis = False for d in D: if d in str(n): dis = True break if not dis: break 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s731247956
p04045
Runtime Error
N, K = map(int,input().split()) D = list(input()) for i in range(N, 10000): M = list(str(i)) if all([M[j] not in D for j in range(len(M))]): ans = int("".join(M)) 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s080285038
p04045
Runtime Error
N,K=map(int,(input().split())) li=[] for i in range(K): li.append(int(input())) for j in range(N,10000): k=0 for t in str(j): if int(t) in li: k=1 break else: if k==0: print(j)
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s096594883
p04045
Runtime Error
N, K = map(int, input().split()) D = list(map(str, input().split())) for i in range(n, 100000): s = list(str(i)) flg = 0 for j in s: if j in d: flg = 1 break if flg == 0: print("".join(s)) 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s256043756
p04045
Runtime Error
#abc 042 c def dfs(i,s): if i==n_keta: if s>=n: kouho.append(s) return 0 for j in range(len(like)): dfs(i+1,s+like[j]) return 0 n,k=input().split() d=list(map(int,input().split())) like=[] for i in range(10): if i not in d: like.append(str(i)) kouho=[] n_keta=len(n) dfs(0,"") if not kouho: n_keta+=1 dfs(0,"") print(min(kouho))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s743844544
p04045
Runtime Error
#abc 042 c def dfs(i,s): if i==n_keta: if s>=n: kouho.append(s) return 0 for j in range(len(like)): dfs(i+1,s+like[j]) return 0 n,k=input().split() d=list(map(int,input().split())) like=[] for i in range(10): if i not in d: like.append(str(i)) kouho=[] n_keta=len(n) dfs(0,"") print(min(kouho))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s952691506
p04045
Runtime Error
n,k = map(int, input().strip().split()) d = list(input().split()) n,k = map(int,input().strip().split()) d = list(input().split()) for x in range(n,100000): for y in d: if y in str(x): break else: print(x) 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s211528341
p04045
Runtime Error
n,k = map(int, input().split()) li = list(map(int, input().split())) Li = list(n) while len(set(Li)&set(li)): n += 1 Li = list(n) else: print("".join(Li))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s842587910
p04045
Runtime Error
n,k = map(int, input().split()) li = list(map(int, input().split())) Li = list(n) while set(Li)&set(li): n += 1 Li = list(n) else: print("".join(Li))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s354621139
p04045
Runtime Error
n,k = map(int, input().split()) li = [] for i in range(k): li.append(int(input())) else: Li = list(n) while not len(set(li)&set(Li)) == 0: n += 1 Li = list(n) else: print("".join(Li))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s116218906
p04045
Runtime Error
n,k = map(int, input().split()) li = [] for i in range(k): li.append(int(input())) else: Li = list(n) while not len(set(li)&set(Li)): n += 1 Li = list(n) else: print("".join(Li))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s433527446
p04045
Runtime Error
n,k = map(int, input().split()) li = [] i = 0 for i<k: li.append(int(input())) i += 1 else: Li = list(n) while not len(set(li)&set(Li)): n += 1 Li = list(n) else: print("".join(Li))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s587931355
p04045
Runtime Error
n,k = map(int, input().split()) li = [] i = 0 for i<k: li.append(int(input())) i += 1 else: Li = list(n) while not set(li)&set(Li) == set(): n += 1 Li = list(n) else: print("".join(Li))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s795267920
p04045
Runtime Error
n,k = map(int, input().split()) li = [] i = 0 for i<k: li.append(int(input())) i += 1 else: Li = list(n) while not set(li)&set(Li) == {}: n += 1 Li = list(n) else: print("".join(Li))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s244751703
p04045
Runtime Error
n,k = map(int, input().split()) li = [] i = 0 for i<k: li.append(int(input())) i += 1 else: Li = list(n) while li&Li: n += 1 Li = list(n) else: print("".join(Li))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s078372369
p04045
Runtime Error
n,k = map(int, input().split()) li = [] i = 0 for i<k: li.append(int(input())) i += 1 else: Li = list(str(n)) while li&Li: n += 1 Li = list(str(n)) else: print("".join(Li))
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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s511104597
p04045
Runtime Error
n, k = map(int, input().split()) d = list(map(int, input().split())) digit = [str(i) for i in range(10) if not i in d] ans = [] stack = [i for i in digit] while stack: s = stack.pop() if int(s) >= n: ans.append(s) else: for i in digit: if len(i+s) <= len(str(n)+1): stack.append(i+s) print(min(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s348035345
p04045
Runtime Error
n, k = map(int, input().split()) d = list(map(int, input().split())) digit = [str(i) for i in range(10) if not i in d] ans = [] stack = [i for i in digit] while stack: s = stack.pop() if int(s) >= n: ans.append(s) else: for i in digit: if len(i+s) <= len(str(n)): stack.append(i+s) print(min(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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s332442476
p04045
Runtime Error
N,K=input().split() D=input().split() while True: for s in D: if N.count(s)!=0: frag=1 else: pass if frag==1: a=int(N)+1 N=str(a) frag=0 else: break 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s984903932
p04045
Runtime Error
N, K = map(int, input().split()) D = list(map(int, input().split())) N_str = str(N) nl = list(N_str) D_str = [] for i in D: D_str.append(str(i)) d_in_n = False for i in nl: if not i in D_str: continue else: d_in_n = True break if d_in_n == False: print(N) else: while len(nl) < 4: nl.insert(0,'0') L = [] for i in range(10): if not i in D: L.append(i) SUB = [] if nl[0] == '0' and nl[1] == '0' and nl[2] == '0': for l in L: N2 = l sub = N2 - N if N2 - N > 0: SUB.append(N2) elif nl[0] == '0' and nl[1] == '0': for k in L: for l in L: N2 = 10*k + l sub = N2 - N if N2 - N > 0: SUB.append(N2) elif nl[0] == '0': for j in L: for k in L: for l in L: N2 = 100*j + 10*k + l sub = N2 - N if N2 - N > 0: SUB.append(N2) else: for i in L: for j in L: for k in L: for l in L: N2 = 1000*i + 100*j + 10*k + l sub = N2 - N if N2 - N > 0: SUB.append(N2) SUB_s = sorted(SUB) print(SUB_s[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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s881618628
p04045
Runtime Error
N, K = map(int, input().split()) D = list(map(int, input().split())) N_str = str(N) nl = list(N_str) D_str = [] for i in D: D_str.append(str(i)) d_in_n = False for i in nl: if not i in D_str: continue else: d_in_n = True break if d_in_n == False: print(N) else: L = [] for i in range(10): if not i in D: L.append(i) SUB = [] for i in L: for j in L: for k in L: for l in L: N2 = 1000*i + 100*j + 10*k + l sub = N2 - N if N2 - N > 0: SUB.append(N2) SUB_s = sorted(SUB) print(SUB_s[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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s132125779
p04045
Runtime Error
N, K = map(int, input().split()) D = list(map(int, input().split())) N_str = str(N) nl = list(N_str) D_str = [] for i in D: D_str.append(str(i)) d_in_n = False for i in nl: if not i in D_str: continue else: d_in_n = True break if d_in_n == False: print(N) else: L = [] for i in range(10): if not i in D: L.append(i) SUB = [] for i in L: for j in L: for k in L: for l in L: N2 = 1000*i + 100*j + 10*k + l sub = N2 - N if N2 - N > 0: SUB.append(N2 - N) SUB_s = sorted(SUB) print(SUB_s[0] + 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s666851219
p04045
Runtime Error
N,K=input().split() dis=list() dis=input().split() while True: for c in dis: if N.count(c)!=0: frag=1 else: pass if frag==1: N=int(N)+1 N=str(N) frag=0 else: break 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s816482826
p04045
Runtime Error
N,K=input().split() dis=list(K) dis=input().split() while True: for c in dis: if N.count(c)!=0: frag=1 else: pass if frag==1: N=int(N)+1 N=str(N) frag=0 else: break 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s854761401
p04045
Runtime Error
N,K=input().split() dis=list(K) dis=input().split() while True: for c in dis: if N.count(c)!=0: frag=1 else: pass if frag==1: N=int(N)+1 N=str(N) frag=0 else: break 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s910077611
p04045
Runtime Error
N, K = map(int, input().split()) D = list(map(str, input().split())) num_set = set(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']) N_list = list(str(N)) diff_list = sorted(list(num_set.difference(set(D)))) if (list(set(D)&set(N_list)) == []): print(N) else: if '0' in diff_list: n_list = [diff_list[1]] + ['0']*len(N_list) else: n_list = [diff_list[0]]*len(N_list+1) str_n = '' for i in n_list: str_n += str(i) new_n = int(str_n)+1 for ii in range(N, new_n): if list(set(list(str(ii)))&set(D)) == []: print(ii) 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s519747783
p04045
Runtime Error
n, k = map(int, input().split()) d = list(map(int, input().split())) a = 0 for i in range(n, 10000): if checknum(i, d): a = i break print(a) def checknum(n, d): for s in str(n): if d.count(int(s)) > 0: return False return True 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s372765487
p04045
Runtime Error
#!/use/bin/env python3 (n, k) = [int(s) for s in input().split()] a = [int(s) for s in input().split()] like = [] ans = n while (1): c = True for ii in range(0, 4): b = b // 10 d = b % 10 if b == 0: break if d in a: c = False break if (c): ans = n break 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s851141967
p04045
Runtime Error
n, k = map(int, input().split()) list_num = [input() for i in range(k)] price = n while True : i = 0 for i in range(len(str(price))) : if str(price)[i] in list_num : price += 1 break else : print(price) 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s942944719
p04045
Runtime Error
from functools import lru_cache N, K = map(int, input().split()) D = input().split() O = [] for c in "0123456789": if c not in D: O.append(c) # N = 523 # D = 2 3 @lru_cache() def func(s, i, over): if i == len(s): return "" # d < N[0] if over: return O[0] + func(s, i+1, over=True) for d in O: if d < s[i]: continue if s[i] == d: return d + func(s, i+1, over=False) return d + func(s, i+1, over=True) print(func(str(N), 0, over=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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>
s553321790
p04045
Runtime Error
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def main(): N, K = map(int, input().split()) D = set(list(map(int, input().split()))) F = set(list(range(10))) - D result = '' for n in str(N): if int(n) in F: result += n else: result += str(min([f for f in F if f > int(n)])) print(result) 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 &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; 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>