submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s114183825
p04045
Accepted
import sys N, K = map(int, input().split()) D = [str(i) for i in input().split()] ans = 0 now = N for j in range(10**6): for i in list(str(now)): if i in D: now += 1 break else: print(now) sys.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>
s749377335
p04045
Accepted
N, K = map(int, input().split()) D = list(map(int, input().split())) m = {} for i in range(10): has_num = False for d in D: if d == i: has_num = True break if has_num: m[i] = True else: m[i] = False min_cost = N while(True): min_cost_list = list(str(min_cost)) num_list = [int(i) for i in min_cost_list] has_num = False for n in num_list: if m[n]: has_num = True if has_num: min_cost += 1 continue else: break print(min_cost)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount 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>
s726268130
p04045
Accepted
N,K = [int(i) for i in input().split()] hate_numbers = [i for i in input().split()] while True: is_okay = True for n in hate_numbers : if (str(N).find(n) == -1) : continue is_okay = False break if (is_okay == True) : print(N) break else : N += 1
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s317258070
p04045
Accepted
N, K = map(int, input().split()) D = list(map(int, input().split())) p = N flag = True while flag: pnum = list(map(int, str(p))) bp = [(i in D) for i in pnum] flag = sum(bp) if flag: p += 1 print(p)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s391899976
p04045
Accepted
N,K = map(int, input().split()) D = input().split() usable = set([str(i) for i in range(10)]) - set(D) # print(usable) for i in range(N, 10000*10): if set(list(str(i))).issubset(usable): 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>
s480802868
p04045
Accepted
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(1000000) # Debug output def chkprint(*args): names = { id(v): k for k, v in inspect.currentframe().f_back.f_locals.items() } print(', '.join( names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args)) # Binary converter def to_bin(x): return bin(x)[2:] def li_input(): return [int(_) for _ in input().split()] def gcd(n, m): if n % m == 0: return m else: return gcd(m, n % m) def gcd_list(L): v = L[0] for i in range(1, len(L)): v = gcd(v, L[i]) return v def lcm(n, m): return (n * m) // gcd(n, m) def lcm_list(L): v = L[0] for i in range(1, len(L)): v = lcm(v, L[i]) return v # Width First Search (+ Distance) def wfs_d(D, N, K): """ D: 隣接行列(距離付き) N: ノード数 K: 始点ノード """ dfk = [-1] * (N + 1) dfk[K] = 0 cps = [(K, 0)] r = [False] * (N + 1) r[K] = True while len(cps) != 0: n_cps = [] for cp, cd in cps: for i, dfcp in enumerate(D[cp]): if dfcp != -1 and not r[i]: dfk[i] = cd + dfcp n_cps.append((i, cd + dfcp)) r[i] = True cps = n_cps[:] return dfk # Depth First Search (+Distance) def dfs_d(v, pre, dist): """ v: 現在のノード pre: 1つ前のノード dist: 現在の距離 以下は別途用意する D: 隣接リスト(行列ではない) D_dfs_d: dfs_d関数で用いる,始点ノードから見た距離リスト """ global D global D_dfs_d D_dfs_d[v] = dist for next_v, d in D[v]: if next_v != pre: dfs_d(next_v, v, dist + d) return def sigma(N): ans = 0 for i in range(1, N + 1): ans += i return ans def comb(n, r): if n - r < r: r = n - r if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2, r + 1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p for k in range(p - 1, r, p): numerator[k - offset] /= pivot denominator[k] /= pivot result = 1 for k in range(r): if numerator[k] > 1: result *= int(numerator[k]) return result def bisearch(L, target): low = 0 high = len(L) - 1 while low <= high: mid = (low + high) // 2 guess = L[mid] if guess == target: return True elif guess < target: low = mid + 1 elif guess > target: high = mid - 1 if guess != target: return False # -------------------------------------------- dp = None def main(): N, K = li_input() D = li_input() price = N while True: dislike = False for p in str(price): if int(p) in D: dislike = True break if not dislike: print(price) return price += 1 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>
s436817592
p04045
Accepted
def abc042_c(): price, len_hate_set = map(int, input().split()) hate_set = set([int(i) for i in input().split()]) usable_set = set(range(0, 10)) - hate_set while True: if all(map(lambda x: int(x) in usable_set, [int(str(price)[i]) for i in range(len(str(price)))])) and price >= price: return price price += 1 if __name__ == '__main__': print(abc042_c())
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s535211246
p04045
Accepted
def abc042_c(): price, len_hate_set = map(int, input().split()) hate_set = set([int(i) for i in input().split()]) while True: if all(map(lambda x: int(x) in set(range(0, 10)) - hate_set, [int(str(price)[i]) for i in range(len(str(price)))])) and price >= price: return price price += 1 if __name__ == '__main__': print(abc042_c())
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s310290199
p04045
Accepted
def abc042_c(): price, len_hate_set = map(int, input().split()) hate_set = set([int(i) for i in input().split()]) ans = price while True: if all(map(lambda x: int(x) in set(range(0, 10)) - hate_set, [int(str(ans)[i]) for i in range(len(str(ans)))])) and ans >= price: return ans ans += 1 if __name__ == '__main__': print(abc042_c())
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s856996581
p04045
Accepted
def abc042_c(): price, len_hate_set = map(int, input().split()) hate_set = set([int(i) for i in input().split()]) usable_list = list(set(range(0, 10)) - hate_set) ans = 0 while True: if all(map(lambda x: int(x) in usable_list, [int(str(ans)[i]) for i in range(len(str(ans)))])) and ans >= price: return ans ans += 1 if __name__ == '__main__': print(abc042_c())
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s993247062
p04045
Accepted
N,K = map(int,input().split()) L = list(map(str,input().split())) flag = 0 while flag == 0 : counter = 0 for c in str(N) : if c not in L : counter += 1 else : break if counter == len(list(str(N))) : flag = 1 else : 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>
s548262677
p04045
Accepted
N,K = map(int,input().split()) L = list(map(str,input().split())) flag = 0 while flag == 0 : counter = 0 for c in str(N) : if c not in L : counter += 1 else : break if counter == len(list(str(N))) : flag = 1 else : 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>
s999190472
p04045
Accepted
# -*- coding: utf-8 -*- N, K = map(int, input().split()) Dk = list(map(int, input().split())) all = [i for i in range(10)] for Di in Dk: if Di in all: all.remove(Di) # print(all) ans = 0 for i in range(N,100000): tmp_list = map(int, list(str(i))) # print(tmp_list) all_ok = True for c in tmp_list: if c in all: pass else: all_ok = False continue if all_ok == True: ans = i break print(ans)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s678678785
p04045
Accepted
N, K = map(int, input().split()) D = list(map(int, input().split())) def hate_num(n): for s in str(n): if int(s) in D: return False return True while True: if hate_num(N): 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>
s963055039
p04045
Accepted
n, k = map(int, input().split()) d = set([int(i) for i in input().split()]) while True: N = set([int(i) for i in str(n)]) if len(N.intersection(d)) == 0: print(n) break else: n += 1
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s656319280
p04045
Accepted
n,k = map(int,input().split()) d = input().split() price = n ans = n while True: flg = True for let in d: if str(n).count(let) > 0: flg = False break if flg != False: 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>
s863377077
p04045
Accepted
def solve(N, K, Ds): while True: c = set([int(c) for c in str(N)]) if len(c.intersection(Ds)) == 0: return N N += 1 if __name__ == "__main__": N, K = map(int, input().split(" ")) Ds = set(map(int, input().split(" "))) print(solve(N, K, Ds))
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount 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>
s871123346
p04045
Accepted
# -*- coding: utf-8 -*- N, K = map(int, input().split()) D = list(map(str, input().split())) flag = True while flag: list_N = list(str(N)) for num in D: if num in list_N: flag = True N += 1 break else: flag = False 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>
s447893086
p04045
Accepted
def main(): N, K = map(int, input().split()) input_d = set(input().split()) while True: n = set(list(str(N))) if not input_d & n: break N += 1 print(N) 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>
s796667941
p04045
Accepted
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(1000000) # Debug output def chkprint(*args): names = { id(v): k for k, v in inspect.currentframe().f_back.f_locals.items() } print(', '.join( names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args)) # Binary converter def to_bin(x): return bin(x)[2:] def li_input(): return [int(_) for _ in input().split()] def gcd(n, m): if n % m == 0: return m else: return gcd(m, n % m) def gcd_list(L): v = L[0] for i in range(1, len(L)): v = gcd(v, L[i]) return v def lcm(n, m): return (n * m) // gcd(n, m) def lcm_list(L): v = L[0] for i in range(1, len(L)): v = lcm(v, L[i]) return v # Width First Search (+ Distance) def wfs_d(D, N, K): """ D: 隣接行列(距離付き) N: ノード数 K: 始点ノード """ dfk = [-1] * (N + 1) dfk[K] = 0 cps = [(K, 0)] r = [False] * (N + 1) r[K] = True while len(cps) != 0: n_cps = [] for cp, cd in cps: for i, dfcp in enumerate(D[cp]): if dfcp != -1 and not r[i]: dfk[i] = cd + dfcp n_cps.append((i, cd + dfcp)) r[i] = True cps = n_cps[:] return dfk # Depth First Search (+Distance) def dfs_d(v, pre, dist): """ v: 現在のノード pre: 1つ前のノード dist: 現在の距離 以下は別途用意する D: 隣接リスト(行列ではない) D_dfs_d: dfs_d関数で用いる,始点ノードから見た距離リスト """ global D global D_dfs_d D_dfs_d[v] = dist for next_v, d in D[v]: if next_v != pre: dfs_d(next_v, v, dist + d) return def sigma(N): ans = 0 for i in range(1, N + 1): ans += i return ans def comb(n, r): if n - r < r: r = n - r if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2, r + 1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p for k in range(p - 1, r, p): numerator[k - offset] /= pivot denominator[k] /= pivot result = 1 for k in range(r): if numerator[k] > 1: result *= int(numerator[k]) return result def bisearch(L, target): low = 0 high = len(L) - 1 while low <= high: mid = (low + high) // 2 guess = L[mid] if guess == target: return True elif guess < target: low = mid + 1 elif guess > target: high = mid - 1 if guess != target: return False # -------------------------------------------- dp = None def main(): N, K = li_input() D = input().split() c_money = N while True: is_dislike = False for a in set(str(c_money)): if a in D: is_dislike = True break if is_dislike: c_money += 1 else: print(c_money) return 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>
s935025249
p04045
Accepted
#! /usr/bin/python3 # こだわり者いろはちゃん / Iroha's Obsession # 参考 : https://abc042.contest.atcoder.jp/submissions/3419872 """ 1≦N<10000 1≦K<10 0≦D1<D2<…<DK≦9 {D1,D2,…,DK}≠{1,2,3,4,5,6,7,8,9} """ N, K = map(int, input().split()) D = set(list(input().split())) test_mode = False def check_num(x, d): """ 金額xの中に中の文字があるか確認する関数。 x : 現在の金額(N, x+1 を想定) d : 嫌いな数字のリスト(D を想定) 文字列 x にリスト d 中の要素が含まれているか、d の要素 num を順に確認し、 含まれていたら1円足して再試行する。 """ if test_mode: print('x =', x) while len(set(list(str(x))) & d) != 0: x += 1 return x def main(): """ 金額を算出して出力 """ amount = check_num(N, D) print(amount) if __name__ == '__main__': main()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s444617329
p04045
Accepted
n,k = map(int, input().split()) d = set(list(input().split())) while len(set(list(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>
s931353588
p04045
Accepted
c, num = map(int, input().split(" ")) arr = list(map(int, input().split(" "))) t = True while t: for x in arr: if str(x) in str(c): break else: t = False break c += 1 if not t: print(c)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s667614173
p04045
Accepted
N,k=map(int,input().split()) K=list(map(str,input().split())) for i in range(N,N+99999): cnt=0 for j in range(k): if K[j] in str(i): cnt+=1 if cnt==0: 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>
s361276446
p04045
Accepted
a = input().split(" ") ar = input().split(" ") count = 0 k = 0 n = int(a[0])-1 while count != 1: n += 1 for b in ar: if b in str(n): k += 1 if k == 0: count += 1 k = 0 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>
s783177935
p04045
Accepted
N, K = map(int, input().split()) D = set(input().split()) frag = True ans = 0 N = N-1 for i in range(0, 1000000): N += 1 if len(set(str(N)) & D) == 0: ans = N frag = False 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>
s247637518
p04045
Accepted
n,k=map(int,input().split());d=input().split() while 1: for c in str(n): if c in d:break else: print(n) exit() n += 1
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s271735358
p04045
Accepted
import sys def exists_allow(string, not_list): for i in not_list: if string.count(str(i)) > 0: return True return False n, k = raw_input().split() n = int(n) d = map(int, raw_input().split()) while True: if exists_allow(str(n), d): n = n + 1 else: print(n) sys.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>
s093464212
p04045
Accepted
n,k = map(int,input().split()) d = list(map(int,input().split())) while 1: for c in str(n): if int(c) in d: break else: print(n) exit() n += 1
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s789117502
p04045
Accepted
N,K = map(int,input().split()) D=input().split() for i in range(N,100001): dame=False for d in D: if d in str(i): dame=True break if dame: continue else: 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>
s712539169
p04045
Accepted
N,K=map(int, input().split()) D=list(input()) for i in range(N,88889): flag=0 for j in list(str(i)): if j in D: flag=1 if flag==0: print(i) 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>
s291304493
p04045
Accepted
N, K = [int(x) for x in input().split()] D = input().split() while True: for i in set(str(N)): if i in D: break else: 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>
s063034572
p04045
Accepted
from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache import sys sys.setrecursionlimit(10000) INF = float("inf") YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no" dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0] dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1] def inside(y, x, H, W): return 0 <= y < H and 0 <= x < W def ceil(a, b): return (a + b - 1) // b def main(): N, K = map(int, input().split()) D = list(input().split()) for n in count(N): ok = True for c in str(n): if c in D: ok = False break if ok: print(n) return if __name__ == '__main__': main()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s502075684
p04045
Accepted
n,k = map(int, input().split()) list_d = list(map(str, input().split())) ans = n ans_list = list(str(ans)) while True: ans_list = list(str(ans)) for number in ans_list: if number in list_d: ans += 1 break else: 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>
s436184993
p04045
Accepted
n, k = map(int, input().split()) array = {int(x) for x in input().split()} mihon = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}^array for i in range(n, 100001): tmp = list(str(i)) tmp = {int(x) for x in tmp} if tmp.issubset(mihon) and 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>
s073578615
p04045
Accepted
N, K = map(int,input().split()) hate = input().split() sw = False while True: N_str = str(N) for i in N_str: if i in hate: break else: sw = True if sw: 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>
s672508665
p04045
Accepted
n=int(input().split()[0]) d=set(input()) while set(str(n))&d: 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>
s156248500
p04045
Accepted
N, K = map(int, input().split()) D = list(map(int, input().split())) i = N while i >= N: work = i while work > 0: if work % 10 in D: break else: work = work // 10 if work > 0: i += 1 continue else: break print(i)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s932002790
p04045
Accepted
n,k = map(int,input().split()) d = input().split() def isValid(num): s = str(num) for c in s: if c in d: return False return True for i in range(n,10*n+1): if isValid(i): 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>
s771373898
p04045
Accepted
iN,iK = [int(x) for x in input().split()] aD = [int(x) for x in input().split()] aUnList = sorted([x for x in range(10) if x not in aD]) aUnList.sort() sN = str(iN) iF = int(sN[0]) def fCheckDigit(sTarget,iL,iPoint,aUnList,aRet,bRev): iF = int(sTarget[iPoint]) aUpper = [x for x in aUnList if x >= iF] aUpper.sort() if bRev: #逆行 #もうひとつ上があるかどうか if len(aUpper) == 1 : #==のとき。もうひとつ上はない if iPoint == 0: if aUnList[0] == 0: return [str(aUnList[1])] + ["0"] * iL else: return [str(aUnList[0])] * (iL + 1) else: return fCheckDigit(sTarget,iL,iPoint -1 , aUnList,aRet,True) else: #上の桁がある return aRet[0:iPoint]+[str(aUpper[1])]+[str(aUnList[0])]*(iL-1-iPoint) else: #順向 if aUpper == []: #大きい数字がないときは逆行して調べる if iPoint == 0: if aUnList[0] == 0: return [str(aUnList[1])] + ["0"] * iL else: return [str(aUnList[0])]*(iL+1) else: return fCheckDigit(sTarget,iL,iPoint-1,aUnList,aRet,True) #逆行する else: if aUpper[0] != iF: return aRet[0:iPoint]+[str(aUpper[0])] + [str(aUnList[0])]*(iL-1- iPoint) else: aRet.append(str(iF)) if iPoint < iL -1 : return fCheckDigit(sTarget,iL,iPoint+1,aUnList,aRet,False) #順行する else: return aRet print( ''.join(fCheckDigit(sN,len(sN),0,aUnList,[],False)))
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s162459914
p04045
Accepted
iN,iK = [int(x) for x in input().split()] aD = [int(x) for x in input().split()] aUnList = sorted([x for x in range(10) if x not in aD]) aUnList.sort() sN = str(iN) iF = int(sN[0]) def fCheckDigit(sTarget,iPoint,aUnList,aRet,bRev): iL = len(sTarget) iF = int(sTarget[iPoint]) aUpper = [x for x in aUnList if x >= iF] aUpper.sort() if bRev: #遡ってきたとき #もうひとつ上があるかどうか if len(aUpper) == 1 : #==のとき。もうひとつ上はない if iPoint == 0: if aUnList[0] == 0: return [str(aUnList[1])] + ["0"] * iL else: return [str(aUnList[0])] * (iL + 1) else: return fCheckDigit(sTarget,iPoint -1 , aUnList,aRet,True) else: #上の桁がある return aRet[0:iPoint]+[str(aUpper[1])]+[str(aUnList[0])]*(iL-1-iPoint) else: #順向 if aUpper == []: #大きい数字がない if iPoint == 0: if aUnList[0] == 0: return [str(aUnList[1])] + ["0"] * iL else: return [str(aUnList[0])]*(iL+1) else: return fCheckDigit(sTarget,iPoint-1,aUnList,aRet,True) #逆行する else: if aUpper[0] != iF: return aRet[0:iPoint]+[str(aUpper[0])] + [str(aUnList[0])]*(iL-1- iPoint) else: aRet.append(str(iF)) if iPoint < iL -1 : return fCheckDigit(sTarget,iPoint+1,aUnList,aRet,False) #順行する else: return aRet print( ''.join(fCheckDigit(sN,0,aUnList,[],False)))
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s738116493
p04045
Accepted
N, K = map(int, input().split()) D = [str(_) for _ in input().split()] Unable = set(D) Fin = False Ans = N while not Fin: if not set(str(Ans)) & Unable: Fin = True else: Ans += 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>
s355146994
p04045
Accepted
n, k = map(int, input().split()) d = list(map(int, input().split())) while True: p = 0 for s in d: if str(s) in str(n): pass else: p += 1 if p==k: print(n) break else: n += 1
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s567009394
p04045
Accepted
n,d = map(int,input().split()) lis = list(map(str,input().split())) cou = n while 1: for i in range(d): if lis[i] in str(cou): break if i == d-1: print(cou) exit() cou += 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>
s824371394
p04045
Accepted
N, K = map(int, input().split()) D = list(map(int, input().split())) n = N while True: i = n while i != 0: if i % 10 in D: break i = i // 10 if i == 0: 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>
s010177376
p04045
Accepted
#!/usr/bin/python3 # -*- coding: utf-8 -*- n, k = [int(i) for i in input().split()] d = [int(i) for i in input().split()] for i in range(n, 100000): f = True for si in str(i): if int(si) in d: f = False if f: 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>
s845503689
p04045
Accepted
N, K = map(int, input().split()) D = list(map(int, input().split())) notD = [i for i in range(0, 10)] for i in D: notD[i] = 10 i = 0 while True: if i >= len(notD): break if notD[i] == 10: del notD[i] i -= 1 i += 1 i = N while True: ans = 1 for j in list(str(i)): for k in D: if int(j) == k: ans = -1 break if ans == -1: break if ans == -1: i += 1 elif ans == 1: 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>
s220441574
p04045
Accepted
N, K = map(int, input().split()) inputs_set = set([i for i in input().split()]) all_set = set({'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}) rest_set = all_set - inputs_set for i in range(N, N*10 + 1): if set(str(i)) <= rest_set: 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>
s500391092
p04045
Accepted
n, k = map(int, input().split()) d = list(map(int, input().split())) for i in range(n, 10 * n + 1): flag = True q = str(i) for j in range(len(q)): if int(q[j]) in d: flag = False break if flag: 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>
s122857837
p04045
Accepted
N , K = map(int,input().split()) lst = input().split() start = N while True: for num in str(start): if num in lst: break else: break start += 1 print(str(start))
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s313719974
p04045
Accepted
N, K = map(int, input().split()) D = set(input().split()) n = N while True: for c in str(n): if c in D: break else: 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>
s618553523
p04045
Accepted
N, K = map(int, input().split()) D = input().split() n = N while True: for c in str(n): if c in D: break else: 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>
s673998066
p04045
Accepted
N, K = map(int, input().split()) D = list(map(int, input().split())) n = N while True: i = n while i != 0: if i % 10 in D: break i = int(i / 10) if i == 0: 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>
s788603791
p04045
Accepted
N, K = map(int, input().split()) D = list(map(int, input().split())) n = N while True: i = n while i != 0: if i % 10 in D: break i = i // 10 if i == 0: 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>
s943728726
p04045
Accepted
N, K = map(int, input().split()) D = list(map(int, input().split())) n = N while True: flg = False for Di in D: if str(Di) in str(n): flg = True if not flg: 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>
s590625486
p04045
Accepted
n,k = map(int,input().split()) hate_nums = list(input().split()) affordable = n while True: is_hate = False for digit in list(str(affordable)): if digit in hate_nums: is_hate = True if is_hate: affordable += 1 else: print(affordable) 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>
s238845076
p04045
Accepted
from itertools import product N, K = map(int, input().split()) D = [int(x) for x in input().split()] def check(x): for s in str(x): if int(s) in D: return False return True for i in range(N, 10 * N): if check(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>
s554966006
p04045
Accepted
N, K = map(int, input().split()) D = [Di for Di in input().split()] for n in range(N, 1000000000): n = str(n) flag = True for ni in n: if ni in D: flag = False break if flag: print(n) exit()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s982966906
p04045
Accepted
n,k=map(int, input().split()) d=list(input().split()) x=n while(1): j=False for t in list(str(x)): if t in d: j=True if j: x+=1 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>
s325118870
p04045
Accepted
a,b = map(int,input().split()) c = input().split() while 1: f = 1 s = str(a) for i in c: if i in s: f = 0 if f : break 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>
s344997370
p04045
Accepted
N, L = map(int, input().split()) D = input().split() ans = N while 1: s = str(ans) f = 1 for i in D: if i in s : f = 0 if f : break ans += 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>
s978230473
p04045
Accepted
def main(): N, L = map(int, input().split()) D = input().split() ans = N while 1: s = str(ans) f = 1 for i in D: if i in s : f = 0 if f : break ans += 1 print(ans) if __name__ == '__main__': main()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s195578349
p04045
Accepted
def main(): N, L = map(int, input().split()) D = input().split() ans = N while 1: s = str(ans) if not [1 for i in D if i in s] : break ans += 1 print(ans) if __name__ == '__main__': main()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s519914117
p04045
Accepted
import itertools n, k = map(int, input().split()) array = {x for x in input().split()} num_array = {str(x) for x in range(10)} like_num = array^num_array res = float("inf") for i in range(1, 100000): tmp = set(list(str(i))) if tmp.issubset(like_num): if n <= i < res: res = i print(res)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s711470071
p04045
Accepted
# -*- coding: utf-8 -*- N,K = map(int, input().split()) Dk = list(map(str, input().split())) for i in range(N, 100000): i = str(i) for j in range(K): if i.find(Dk[j]) != -1: break if j == K-1: 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>
s779816647
p04045
Accepted
n, k = map(int, input().split(" ")) d = input().split(" ") while set(str(n)) & set(d): 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>
s023060383
p04045
Accepted
n=int(input().split()[0]) d=set(input()) while len(set(str(n))&d): 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>
s904619756
p04045
Accepted
n, k = map(int, input().split()) d = input().split() while len(set(str(n)) & set(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>
s574788282
p04045
Accepted
N, K=map(int,input().split()) D=list(map(int,input().split())) ans=N while ans<99999: flag=False num = list(map(int, str(ans))) for i in range(K): for digit in num: if digit==D[i]: ans +=1 flag=True break if flag: break if flag==False: 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>
s738255093
p04045
Accepted
from collections import defaultdict,deque import sys,heapq,bisect,math,itertools,string,queue,datetime sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inpl(): return list(map(int, input().split())) def inpl_s(): return list(input().split()) N,K = inpl() dd = inpl() def check(N): tmp = list(map(int,list(str(N)))) for t in tmp: if t in dd: return False return True while True: if check(N): 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>
s557145147
p04045
Accepted
n, k = map(int, input().split()) d = list(map(int, input().split())) s = set(d) N = str(n) flag = 1 for i in N: if int(i) in s: flag = 0 if flag: print(n) else: while True: n += 1 N = str(n) flag = 1 for i in N: if int(i) in s: flag = 0 if flag: 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>
s576371435
p04045
Accepted
N,K = map(int, input().split()) D = set(list(map(int, input().split()))) ans = 0 for i in range(N, 10*N+1): res = i while res > 0: digit = res % 10 if digit in D: break res //= 10 if res <= 0: ans = i break print(ans)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s816547342
p04045
Accepted
N,K=[int(i) for i in input().split()] D=[int(i) for i in input().split()] INF = 99999999 for i in range(N,INF): for d in D: if str(d) in str(i): break else: print(i) break #print(i)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s651879505
p04045
Accepted
N,K = map(int,input().split()) D = set(input().split()) while True: for c in str(N): if c in D: break else: print(N) exit() 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>
s799739126
p04045
Accepted
#-*-coding:utf-8-*- def main(): #n, k = input().split() n, k = map(int, input().split()) d_list = list(map(int, input().split())) while True: if all(x not in d_list for x in list(map(int, list(str(n))))): ans = n break n += 1 print(ans) if __name__ == '__main__': main()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s299147467
p04045
Accepted
#-*-coding:utf-8-*- import itertools def solve(like_list, n, rp, ans): for i in itertools.product(like_list, repeat=rp): if i[0] != 0: num = int(''.join(map(str, i))) if num >= int(n): ans = min(ans, num) return ans def main(): n, k = input().split() d_list = list(map(int, input().split())) like_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] for i in d_list: like_list.remove(i) ans = float('inf') ans = solve(like_list, n, len(n), ans) if ans == float('inf'): ans = solve(like_list, n, len(n)+1, ans) print(ans) if __name__ == '__main__': main()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s305997477
p04045
Accepted
N, K = map(int, input().split()) D = list(map(int, input().split())) def check(a): s = str(a) for i in s: if int(i) in D: return True return False n = N while check(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>
s439601595
p04045
Accepted
N, K = map(int, input().split()) D = input().split() for i in range(N, 10 * N + 1): for j in str(i): if j in D: break else: 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>
s444364727
p04045
Accepted
# -*- coding: utf-8 -*- """ Created on Sat Aug 4 15:31:00 2018 @author: maezawa """ n, k = list(map(int, input().split())) d = frozenset(list(map(str, input().split()))) ok = frozenset(list(map(str,range(10)))) - d for i in range(n, 100000): if frozenset(str(i)) <= ok: 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>
s498397135
p04045
Accepted
from itertools import product as p n,k=map(int,input().split()) e={i for i in range(10)} d=e^set(map(int,input().split())) f=lambda x:int("".join(map(str,x))) g=lambda x:x>=n h=sorted(filter(g,map(f,p(d,repeat=len(str(n)))))) if h: print(h[0]) else: h=sorted(filter(g,map(f,p(d,repeat=len(str(n))+1)))) print(h[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>
s531781840
p04045
Accepted
N, K = [int(i) for i in input().split()] D = [s for s in input().split()] ans = N while(True): for i in range(len(str(ans))): if str(ans)[i] in D: ans += 1 break else: 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>
s832252351
p04045
Accepted
N, K = input().split() D = [int(x) for x in input().split()] L = [str(i) for i in range(10) if i not in D] ANS = '' for i, n in enumerate(N): if n in L: ANS += n elif int(L[-1]) > int(n): ANS += [l for l in L if int(l) > int(n)][0] ANS += L[0] * (len(N) - len(ANS)) break else: while ANS: c = ANS[-1] ANS = ANS[:-1] if int(L[-1]) > int(c): ANS += [l for l in L if int(l) > int(n)][0] break if ANS: ANS += L[0] * (len(N) - len(ANS)) else: ANS = (L[0] if int(L[0]) else L[1]) + L[0] * len(N) 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>
s951277369
p04045
Accepted
N, K = map(int, input().split()) D = set(input().split()) while any(x in D for x in 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>
s054452127
p04045
Accepted
def main(): n, k = map(int,input().split()) d = list(input().split()) ans = n Flag = False while True: for i in range(k): if list(str(ans)).count(d[i]) > 0: ans+=1 Flag = True break if i == k -1: print(ans) exit() 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>
s342166572
p04045
Accepted
N, K = map(int, input().split()) D = [Di for Di in input().split()] for n in range(N, 1000000000): n = str(n) flag = True for i in range(len(str(n))): if n[i] in D: flag = False break if flag is True: print(n) exit()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s300253223
p04045
Accepted
n, k = map(int, input().split()) d = list(map(int, input().split())) flag = True while any([i==j for i in list(map(int, list(str(n)))) for j in d]): 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>
s698852810
p04045
Accepted
n,m=map(int,input().split()) k=list(map(int,input().split())) f=1 now=n while f>0: a=[] b=now while b>0: a.append(b%10) b=b//10 f2=-1 for c in a: if c in k: f2=1 if f2>0: now+=1 else: f=-1 print(now)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount 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>
s536527691
p04045
Accepted
n,k = map(int,raw_input().split()) arr = [0,1,2,3,4,5,6,7,8,9] r = map(int,raw_input().split()) for i in r: arr.remove(i) def count_digit(num): count = 0 t = num while t > 0 : count += 1 t /= 10 return count dc = count_digit(n) + 1 ans = float("inf") def dfs(s,i): global ans,n,dc ret = int(s) if i > 0 else 0 if ret >= n : ans = min(ans,ret) if i != dc : for j in arr : dfs(s + str(j),i + 1) dfs('',0) print ans
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s499933307
p04045
Accepted
def inpl(): return input().split() n, k = map(int, inpl()) d = inpl() x = n while True: flg = True for c in str(x): if c in d: flg = False break if flg: break x += 1 print(x)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s542420708
p04045
Accepted
N, K = map(int, input().split()) d = [int(x) for x in input().split()] avail = [x for x in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] if x not in d] i = 0 while 1 : okflg = True for c in (str(N + i)) : if int(c) not in avail : okflg = False if okflg == True : print(N + i) break 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>
s598551920
p04045
Accepted
N, K = [int(i) for i in input().split()] d = [s for s in input().split()] ans = N while(True): sAns = str(ans) for i in range(len(sAns)): if sAns[i] in d: ans += 1 break else: 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>
s426593682
p04045
Accepted
import itertools str_n, str_k = input().split() n = int(str_n) k = int(str_k) d = set([int(di) for di in input().split()]) opt = list({0,1,2,3,4,5,6,7,8,9} - d) def isok(num): if set([int(_) for _ in list(str(num))]) - set(opt) == set(): return True else: return False i = 0 while True: if isok(n + i): print(n + i) break 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>
s455986740
p04045
Accepted
N, K = map(int, input().split()) D = list(map(int, input().split())) while True: flag = 1 N_str = list(str(N)) for s in N_str: if int(s) in D: flag = 0 break if flag: 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>
s345367336
p04045
Accepted
import itertools, math n, k = input().split() nums = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} - {x for x in input().split()} length = len(n) coms = itertools.product(nums, repeat=length+1) n = int(n) ans = float("inf") for com in coms: tmp = "".join(com) if n <= int(tmp) < ans: ans = int(tmp) coms = itertools.product(nums, repeat=length) for com in coms: tmp = "".join(com) if n <= int(tmp) < ans: ans = int(tmp) print(ans)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s046008942
p04045
Accepted
import itertools, math n, k = input().split() nums = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} - {x for x in input().split()} length = len(n) coms = itertools.product(nums, repeat=length) n = int(n) ans = float("inf") for com in coms: tmp = "".join(com) if n <= int(tmp) < ans: ans = int(tmp) coms = itertools.product(nums, repeat=length+1) for com in coms: tmp = "".join(com) if n <= int(tmp) < ans: ans = int(tmp) print(ans)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s296046275
p04045
Accepted
n,k=map(int,input().split()) d=list(map(int,input().split())) while True: change=False for i in str(n): if int(i) in d: n+=1 change=True break if change==False: 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>
s812802452
p04045
Accepted
n, k = list(map(int, input().split())) d = list(map(int, input().split())) while(True): contain = False for nn in str(n): if int(nn) in d: contain = True n += 1 break if not contain: 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>
s070182815
p04045
Accepted
n, k = map(int, raw_input().split()) d = set(raw_input().split()) found = False while True: a = set(str(n)) if a & d: n += 1 continue 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>
s793349369
p04045
Accepted
n, k = [int(i) for i in input().split()] d = [i for i in input().split()] can = False while not can: can = True n_str = str(n) for num in n_str: if num in d: can = False n += 1 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>
s426684064
p04045
Accepted
n, k = map(int,input().split()) unlike = list(map(int,input().split())) while 1: for n_i in str(n): if int(n_i) in unlike: 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>