submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s864160136
p04045
Accepted
N, K = list(map(int, input().split())) D = list(map(int, input().split())) while True: for N_i in str(N): if int(N_i) in D: 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>
s270468884
p04045
Accepted
n, k = (int(char) for char in input().split()) d = [int(i) for i in input().split()] ''' n = 10 k = 8 d = [0, 2, 3] ''' D = [i for i in range(10)] like_vals = [int(str(i)) for i in D if i not in d] i = 0 n = [int(str(n)[i]) for i in range(len(str(n)))] r = [-1] * len(n) while i < len(n): if n[i] in like_vals: r[i] = n[i] i += 1 elif n[i] < max(like_vals): like_bigger = [like_val for like_val in like_vals if like_val > n[i]] r[i] = min(like_bigger) for j in range(i + 1, len(n)): r[j] = min(like_vals) break else: r = [-1] * (len(n) + 1) if min(like_vals) != 0: r[0] = min(like_vals) else: r[0] = min([like_val for like_val in like_vals if like_val != 0]) for j in range(1, len(n) + 1): r[j] = min(like_vals) break newr = "" for _r in r: newr += str(_r) newr = int(newr) print(newr)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount 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>
s520919188
p04045
Accepted
from itertools import product def generator(ls, length): for i in product(*(ls for i in range(length))): yield "".join(i) def solve(ls, n): for i in generator(ls, len(n)): if n <= i: return i if ls[0] == "0": return ls[1] + "".join(ls[0] for i in range(len(n))) return "".join(ls[0] for i in range(len(n) + 1)) if __name__ == "__main__": n, k = input().split() ls = {chr(i) for i in range(ord("0"), ord("0") + 10)} ls.difference_update(set(input())) ls = sorted(ls) print(solve(ls, 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>
s136630325
p04045
Accepted
n,k=map(int, input().split()) d=list(input().split()) ans=10000 for i in range(n,100000): for j in d: if str(i).count(j):break else: ans=i break print(ans)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s553092332
p04045
Accepted
n,k = map(int,input().split()) d = list(map(str,input().split())) flg = True while flg: l = list() n_s = str(n) for i in n_s: if i in d: break else: print(n) flg = False break n = n +1 else: 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>
s998082072
p04045
Accepted
def m(): def is_included(i,d): s = str(i) for j in d: if str(j) in s: return True return False n, k = map(int, input().split()) d = list(map(int, input().split())) for i in range(n, n*10): if not is_included(i,d): return i return 0 print(m())
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; D_K≦9</var></li> <li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li> </ul> </section> </div> <hr/> <div class="io-style"> <div class="part"> <section> <h3>Input</h3><p>The input is given from Standard Input in the following format:</p> <pre><var>N</var> <var>K</var> <var>D_1</var> <var>D_2</var> … <var>D_K</var> </pre> </section> </div> <div class="part"> <section> <h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p> </section> </div> </div> <hr/> <div class="part"> <section> <h3>Sample Input 1</h3><pre>1000 8 1 3 4 5 6 7 8 9 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 1</h3><pre>2000 </pre> <p>She dislikes all digits except <var>0</var> and <var>2</var>.</p> <p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p> </section> </div> <hr/> <div class="part"> <section> <h3>Sample Input 2</h3><pre>9999 1 0 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 2</h3><pre>9999 </pre></section> </div> </span>
s538490405
p04045
Accepted
n, k = map(int, input().split()) d = list(map(int, input().split())) for i in range(10*n+2): if i >= n: s = str(i) for j in range(len(s)): if int(s[j]) in d: break else: print(i) 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>
s735120669
p04045
Accepted
n, k = map(int, input().split()) d = list(map(int, input().split())) def solve(): for i in range(10*n+2): if i >= n: s = str(i) for j in range(len(s)): if int(s[j]) in d: break else: print(i) return 0 solve()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; D_K≦9</var></li> <li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li> </ul> </section> </div> <hr/> <div class="io-style"> <div class="part"> <section> <h3>Input</h3><p>The input is given from Standard Input in the following format:</p> <pre><var>N</var> <var>K</var> <var>D_1</var> <var>D_2</var> … <var>D_K</var> </pre> </section> </div> <div class="part"> <section> <h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p> </section> </div> </div> <hr/> <div class="part"> <section> <h3>Sample Input 1</h3><pre>1000 8 1 3 4 5 6 7 8 9 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 1</h3><pre>2000 </pre> <p>She dislikes all digits except <var>0</var> and <var>2</var>.</p> <p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p> </section> </div> <hr/> <div class="part"> <section> <h3>Sample Input 2</h3><pre>9999 1 0 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 2</h3><pre>9999 </pre></section> </div> </span>
s749491146
p04045
Accepted
N,K = map(int, input().split()) D = input().split() for ans in range(N,N*10+1): ch_n = str(ans) cnt = 0 for c in ch_n: cnt += 1 if c in D: break if cnt == len(ch_n): print(ans) 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>
s346796503
p04045
Accepted
def main(): N, K = map(int, raw_input().split()) D = raw_input().split() for i in range(N, N*10): if len(set(list(str(i))) & set(D)) == 0: print i break 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>
s575958080
p04045
Accepted
n,k = map(int, input().split()) d = set(input().split()) ans = 99999 for i in range(n, n*10): if set(str(i)) & d == set(): 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>
s053701914
p04045
Accepted
N, K = map(int, input().split()) d = set([int(i) for i in input().split()]) while True: e = {int(i) for i in str(N)} if d & e == set({}): 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>
s295399989
p04045
Accepted
N,K = map(int, input().split()) hate = [i for i in input().split()] j = 0 k = 0 while j >= 0: k = 0 for nums in hate: if nums in str(N): k += 1 else: pass if k == 0: break 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>
s105043683
p04045
Accepted
def main(): N, K = map(int, input().split()) D = list(input().split()) while True: S = str(N) f = True for s in S: if s in D: f = False break if f: 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>
s134023085
p04045
Accepted
def main(): N, K = map(int, input().split()) D = list(input().split()) i = 0 while True: S = str(N) f = True for s in S: if s in D: f = False break if f: 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>
s023047063
p04045
Accepted
n, k = map(int, input().split()) d = set(input().split()) ans=10000 for i in range(n, n*10): if set(str(i)) & d == set(): 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>
s169384706
p04045
Accepted
N, K = map(int, input().split()) D = set(input().split()) while True: if not set(str(N)) & D: 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>
s846590821
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
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount 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>
s416983751
p04045
Accepted
N, K = map(int, input().split()) D = set(input().split()) while True: if not set(str(N)) & D: 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>
s268980885
p04045
Accepted
def main(): N, K = map(int, input().split()) *D, = map(int, input().split()) price = N while True: a = False for x in D: if str(x) in str(price): a = True break if not a: break price += 1 print(price) 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>
s621056185
p04045
Accepted
def find_next_valid_digit(d, bad_nums): next_digit = d while True: valid = True for c in str(next_digit): if int(c) in bad_nums: valid = False break if valid: break else: next_digit += 1 return next_digit if __name__ == '__main__': n, k = list(map(int, input().split(' '))) bad_nums = list(map(int, input().split(' '))) n_str = str(n) cur_result = 0 for i in range(len(n_str)): most_significant_digit = int(n_str[i]) if most_significant_digit in bad_nums: basis = cur_result * 10 + most_significant_digit cur_result = find_next_valid_digit(basis, bad_nums) num_digits_to_fill = (len(n_str) - i - 1) num_to_fill = find_next_valid_digit(0, bad_nums) if num_digits_to_fill > 0: cur_result = (cur_result * (10**num_digits_to_fill)) + int(str(num_to_fill) * num_digits_to_fill) break else: cur_result = cur_result * 10 + most_significant_digit print(cur_result)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s532262970
p04045
Accepted
n,k=map(int,input().split()) d=list(map(int,input().split())) for i in range(n,10*n+1): judge=True num=list(str(i)) num=map(int,num) if set(num)&set(d): judge=False if judge: 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>
s932765737
p04045
Accepted
def main(): n, k = map(int, input().split()) d = set(map(int, input().split())) for i in range(n, 90000): for j in str(i): if int(j) in d: break else: print(i) break 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>
s911952934
p04045
Accepted
x,n=[int(i) for i in input().split()] a=[i for i in input().split()] f=0 while True: for i in set(list(str(x))): if i in a: break else: print(x) break x+=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>
s982005369
p04045
Accepted
N, K = map(int, raw_input().split()) D = raw_input().split() while True: flag = True for i in range(0, len(str(N))): if str(N)[i] in D: flag = False break if flag: print N break else: N = N + 1
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s499192591
p04045
Accepted
def c_iroha_obsession(N, K, D): for ans in range(N, 10 * N + 1): for digit in str(ans): # 1桁ずつ調べる if int(digit) in D: # 嫌いな数字があった break else: # 嫌いな数字がなかった。このときのansが解 break return ans N,K = [int(i) for i in input().split()] D = [int(i) for i in input().split()] print(c_iroha_obsession(N, K, D))
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s875626069
p04045
Accepted
n,k=map(int,input().split()) d=set(map(str,input().split())) while True: flag=True a=list(str(n)) for i in range(len(str(n))): if str(n)[i] in d: flag=False n+=1 break if flag: 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>
s805990068
p04045
Accepted
def check(d, x): x = str(x) for xx in x: if int(xx) not in d: return False return True n, k = map(int, input().split()) d = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ^ set(map(int, input().split())) i = n while 1: if check(d, i): break i += 1 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>
s056153926
p04045
Accepted
l = list(map(int,input().split())) n,k = l[0],l[1] d = list(map(int,input().split())) for i in range(n,10*n+1): flag = 0 s = list(str(i)) for j in s: if int(j) in d: flag = 1 break if flag == 0: print(i) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s026199051
p04045
Accepted
def main(): N, K = map(int, input().split()) D = set(map(int, input().split())) for i in range(10): if i not in D: min_ = i break ans = [] apnd = ans.append num, top, i = N, 0, 0 while num > 0: while num % 10 in D: num += 1 top = i num, m = divmod(num, 10) apnd(m) i += 1 ans[0:top] = [min_] * top print(*ans[::-1], sep='') main()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s675256811
p04045
Accepted
N, K = map(int, input().split(' ')) hate = list(map(int, input().split(' '))) allow = set([0,1,2,3,4,5,6,7,8,9]) - set(hate) for i in range(N, 88889): tmp_set = set(map(int, list(str(i)))) if tmp_set <= allow: 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>
s490575432
p04045
Accepted
N,K = map(int,input().split()) ban = set(input().split()) while True: for c in str(N): if c in ban: 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>
s366228117
p04045
Accepted
n,k = [int(i) for i in input().split()] D = [i for i in input().split()] c = n def match(A,B): for a in A: if a in B: return True else: return False while True: if match(D,list(str(c))): c += 1 continue else: break 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>
s931703580
p04045
Accepted
n, k = map(int, input().split()) o = set(input().split()) while True: if set(str(n)).intersection(o): n += 1 else: break print(n)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; D_K≦9</var></li> <li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li> </ul> </section> </div> <hr/> <div class="io-style"> <div class="part"> <section> <h3>Input</h3><p>The input is given from Standard Input in the following format:</p> <pre><var>N</var> <var>K</var> <var>D_1</var> <var>D_2</var> … <var>D_K</var> </pre> </section> </div> <div class="part"> <section> <h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p> </section> </div> </div> <hr/> <div class="part"> <section> <h3>Sample Input 1</h3><pre>1000 8 1 3 4 5 6 7 8 9 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 1</h3><pre>2000 </pre> <p>She dislikes all digits except <var>0</var> and <var>2</var>.</p> <p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p> </section> </div> <hr/> <div class="part"> <section> <h3>Sample Input 2</h3><pre>9999 1 0 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 2</h3><pre>9999 </pre></section> </div> </span>
s171222717
p04045
Accepted
N,M=map(int,input().split()) s=list(input().split()) q=1 while q==1: for i in list(str(N)): if i in s: N=N+1 break else: print(N) q=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>
s621961588
p04045
Accepted
N,K = map(int,input().split()) D = set(input().split()) while True: if not set(str(N)) & D: 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>
s889294465
p04045
Accepted
n, l = [int(i) for i in input().split()] d = {i for i in input().split()} while True: if not set(str(n)) & d: 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>
s178618659
p04045
Accepted
N, K = map(int,input().split()) D = list(map(int,input().split())) ans = N while True: str_a = str(ans) OK = True for s in str_a: if int(s) in D: OK = False break if OK: 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>
s005624284
p04045
Accepted
n, k = list(map(int, input().split())) d = list(map(int, input().split())) if 0 in d: zero = True else: zero = False n_ok = {0} | set([0,1,2,3,4,5,6,7,8,9]) - set(d) n_oks = sorted(n_ok) #print(n_oks) def lowest(): for i in n_oks: for j in n_oks: for k in n_oks: for l in n_oks: for m in n_oks: money = 10000*i +1000*j + 100*k + 10*l + m if money >= n: if zero: if 0 in [i,j,k,l,m] and i != 0: continue elif 0 in [j,k,l,m] and j != 0: continue elif 0 in [k,l,m] and k != 0: continue elif 0 in [l,m] and l != 0: continue print(money) return lowest()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s662529053
p04045
Accepted
n, k = list(map(int, input().split())) d = list(map(int, input().split())) if 0 in d: zero = True else: zero = False n_ok = {0} | set([0,1,2,3,4,5,6,7,8,9]) - set(d) n_oks = sorted(n_ok) #print(n_oks) def lowest(): for i in n_oks: for j in n_oks: for k in n_oks: for l in n_oks: for m in n_oks: money = 10000*i +1000*j + 100*k + 10*l + m if money >= n: if zero: if 0 in [i,j,k,l,m] and i != 0: continue elif 0 in [j,k,l,m] and j != 0: continue if 0 in [k,l,m] and k != 0: continue if 0 in [l,m] and l != 0: continue print(money) return lowest()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s305613222
p04045
Accepted
N,K=map(int,input().split()) D=[int(i) for i in input().split()] T=[0 for i in range(10)] for i in D: T[i]=1 S=[] for i in range(10): if T[i]==0: S.append(i) import itertools L=[] R=[] if N>=1000: L=list(itertools.product(S,S,S,S)) R=sorted([int(str(i[0])+str(i[1])+str(i[2])+str(i[3])) for i in L]) elif N>=100: L=list(itertools.product(S,S,S)) R=sorted([int(str(i[0])+str(i[1])+str(i[2])) for i in L]) elif N>=10: L=list(itertools.product(S,S)) R=sorted([int(str(i[0])+str(i[1])) for i in L]) else: L=list(itertools.product(S)) R=sorted([int(str(i[0])) for i in L]) P=len(str(N)) for i in R: if int(i)>=N: print(i) exit() if S[0]!=0: print(str(S[0])*(P+1)) else: print(str(S[1])+"0"*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>
s122108311
p04045
Accepted
### -*- coding: utf-8 -*- INPUT = input() N = int(INPUT.split()[0]) # N_list = [int(x) for x in list(str(N))] # K = int(INPUT.split()[1]) D_list = map(int, input().split()) DIGITS = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0} # usable_digits = list(DIGITS - set(D_list)) usable_digits = DIGITS - set(D_list) while True: N_set = set([int(x) for x in list(str(N))]) if N_set <= usable_digits: 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>
s909756001
p04045
Accepted
l = list(map(int,input().split())) n = l[0] k = l[1] d = list(map(int,input().split())) n_str = list(str(n)) can_use = [] for i in range(10): can_use.append(i) for j in d: can_use.remove(j) for i in range(len(n_str)): j = int(n_str[i]) n_str[i] = j ss = [] for i in range(n * 10 + 1): ss.append(n + i) aaa = 0 for j in ss: jl = list(str(j)) for k in range(len(jl)): m = int(jl[k]) jl[k] = m if set(jl) <= set(can_use): aaa = jl break bbb = '' for i in aaa: bbb = bbb + str(i) print(int(bbb))
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount 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>
s122609494
p04045
Accepted
n, k = map(int, input().split()) l = list(map(int, input().split())) nums = [i for i in range(10) if not i in l] while True: total = 0 for num in nums: total += list(str(n)).count(str(num)) if total == len(list(str(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>
s418595035
p04045
Accepted
input_array = list(map(int,input().split())) N = input_array[0] input_array = list(map(int,input().split())) num = [1,1,1,1,1,1,1,1,1,1] ok = [] out = [] for l in range(len(input_array)): num[input_array[l]] = 0 for i in range(len(num)): if num[i] == 0: ok.append(i) while True: key = 0 for n in list(str(N)): if int (n) in ok: key += 1 if key == 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>
s734020243
p04045
Accepted
n,k = (int(i) for i in input().split()) d = [int(i) for i in input().split()] for i in range(n,88889): a = str(i) if all(int(j) not in d for j in a): print(i) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s684753809
p04045
Accepted
li_1 = list(map(int,input().split())) N = li_1[0] K = li_1[1] D = list(map(int,input().split())) minvalue=N temp=0 for i in range(10*N): i=i+N numtemp=i if numtemp>=10000: num_4=int(i/10000) i=i-10000*num_4 else: num_4=10 if numtemp>=1000: num_3=int(i/1000) i=i-1000*num_3 else: num_3=10 if numtemp>=100: num_2=int(i/100) i=i-100*num_2 else: num_2=10 if numtemp>=10: num_1=int(i/10) i=i-10*num_1 else: num_1=10 num_0=i for j in range(K): if (num_0!=D[j])and(num_1!=D[j])and(num_2!=D[j])and(num_3!=D[j])and(num_4!=D[j]): temp+=1 if temp==K: num=numtemp break temp=0 print(num)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s628513182
p04045
Accepted
from functools import reduce N, _ = [int(s) for s in input().split()] D = [s for s in input().split()] R = N while True: if reduce(lambda x, y: x and y, [s not in D for s in list(str(R))]): break R += 1 print(R)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s442370279
p04045
Accepted
a,b=map(int,(input().split())) c=set(input()) while sum(i in c for i in str(a))>0: 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>
s628552669
p04045
Accepted
from functools import reduce def obsession(n, disliked): def nearest(digit): for i in range(digit, digit + 10): mod10 = i % 10 if mod10 not in disliked: return (mod10, i != mod10) will_pay = list(map(int, str(n))) index = 0 while index < len(will_pay): digit = will_pay[index] if digit in disliked: substitute, carry = nearest(digit) will_pay[index] = substitute # Propagate zeroes (or nearest) to the right i = index + 1 substitute, _ = nearest(0) while i < len(will_pay): will_pay[i] = substitute i += 1 # Propagate carry to the left i = index - 1 while carry and i >= 0: substitute, carry = nearest(will_pay[i] + 1) will_pay[i] = substitute i -= 1 if carry: will_pay.insert(0, nearest(1)[0]) index += 1 index += 1 return reduce(lambda x, y: x * 10 + y, will_pay, 0) if __name__ == '__main__': n, _ = map(int, input().split()) disliked = set(map(int, input().split())) print(obsession(n, disliked))
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s252052817
p04045
Accepted
import sys debug_mode = True if len(sys.argv) > 1 and sys.argv[1] == "-d" else False if debug_mode: import os inf = open(os.path.basename(__file__).replace(".py", ".in")) def input(): return inf.readline() else: inf = sys.stdin # ============================================================== def main(): n, k = [int(x) for x in input().strip().split()] d = [x for x in input().strip().split()] while True: str_n = str(n) if any(i in str_n for i in d): n += 1 else: break print(n) main() # ============================================================== if debug_mode: inf.close()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount 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>
s243691418
p04045
Accepted
N,K=map(int,input().split()) A=[int(x) for x in input().split()] def check(a): a=str(a) for i in range(len(a)): if int(a[i]) in A: return False return True while not 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>
s246427685
p04045
Accepted
n,k=map(int,input().split()) d=set(map(str,input().split())) for i in range(n,10*n): a=list(str(i)) a=set(a) if a&d==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>
s956927842
p04045
Accepted
n,k=map(int,input().split()) d=list(input().split()) for i in range(n,100001): set_i=set(list(str(i))) for j in set_i: if j in d: break else: print(i) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s197362302
p04045
Accepted
n,k=map(int,input().split()) d=list(input().split()) ans=n p=0 for i in range(10*n+1): s=str(ans) for j in range(len(str(s))): if s[j] in d: break else: 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>
s848328033
p04045
Accepted
# -*- coding: utf-8 -*- """ https://beta.atcoder.jp/contests/abc042/tasks/arc058_a AC """ import sys from sys import stdin input = stdin.readline def solve(forbiddens, N): forbiddens = set(forbiddens) ans = N repeat = True while repeat: repeat = False num_s = str(ans) for s in num_s: if int(s) in forbiddens: repeat = True ans += 1 break return ans def main(args): # N, K = 9999, 1 # forbiddens = [9] N, K = map(int, input().split()) forbiddens = [int(x) for x in input().split()] ans = solve(forbiddens, N) print(ans) if __name__ == '__main__': main(sys.argv[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>
s805171138
p04045
Accepted
# -*- coding: utf-8 -*- """ https://beta.atcoder.jp/contests/abc042/tasks/arc058_a """ import sys from sys import stdin input = stdin.readline def solve(forbiddens, N): forbiddens.sort() ans = N repeat = True while repeat: repeat = False num_s = str(ans) for s in num_s: if int(s) in forbiddens: repeat = True ans += 1 break return ans def main(args): # N, K = 9999, 1 # forbiddens = [9] N, K = map(int, input().split()) forbiddens = [int(x) for x in input().split()] ans = solve(forbiddens, N) print(ans) if __name__ == '__main__': main(sys.argv[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>
s711734556
p04045
Accepted
price, num = map(int,input().split()) dislike = list(input().split()) ans = price p = 0 for i in range(10*price+1): s = str(ans) for j in range(len(str(s))): if s[j] in dislike: break else: 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>
s465752526
p04045
Accepted
def main(): n, k = map(int, input().split()) D = list(map(int, input().split())) while 1: f = 0 hoge = str(n) for i in range(len(hoge)): for j in range(k): if(int(hoge[i]) == D[j]): f = 1 break if f == 1: break if f == 1: break if f == 0: print(n) break n += 1 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>
s275439687
p04045
Accepted
def c_IrohaObsession(N, K, D): d = [str(i) for i in D] i = N while True: for c in str(i): if c in d: break else: return i i += 1 N,K = [int(i) for i in input().split()] D = [int(i) for i in input().split()] print(c_IrohaObsession(N, K, D))
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s996179481
p04045
Accepted
(n, k), d = map(int, raw_input().split()), set(raw_input().split()) for _ in xrange(n, 100001): if not set(str(_)) & d: print _ break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s692800942
p04045
Accepted
N, K = map(int, input().split()) D = set(map(str, input().split())) for i in range(N, 100000): a = list(str(i)) a = set(a) if a & D == 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>
s686126900
p04045
Accepted
def solve(d,s): for i in range(len(d)): if d[i] in s: return 1 return 0 N,K = map(int,input().split()) D = list(map(str,input().split())) m = N while solve(D,str(m)): m += 1 print(m)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; D_K≦9</var></li> <li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li> </ul> </section> </div> <hr/> <div class="io-style"> <div class="part"> <section> <h3>Input</h3><p>The input is given from Standard Input in the following format:</p> <pre><var>N</var> <var>K</var> <var>D_1</var> <var>D_2</var> … <var>D_K</var> </pre> </section> </div> <div class="part"> <section> <h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p> </section> </div> </div> <hr/> <div class="part"> <section> <h3>Sample Input 1</h3><pre>1000 8 1 3 4 5 6 7 8 9 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 1</h3><pre>2000 </pre> <p>She dislikes all digits except <var>0</var> and <var>2</var>.</p> <p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p> </section> </div> <hr/> <div class="part"> <section> <h3>Sample Input 2</h3><pre>9999 1 0 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 2</h3><pre>9999 </pre></section> </div> </span>
s764905909
p04045
Accepted
n=int(input().split()[0]) d=set(input()) while len(set(str(n))&d)>0: n+=1 print(n)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; D_K≦9</var></li> <li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li> </ul> </section> </div> <hr/> <div class="io-style"> <div class="part"> <section> <h3>Input</h3><p>The input is given from Standard Input in the following format:</p> <pre><var>N</var> <var>K</var> <var>D_1</var> <var>D_2</var> … <var>D_K</var> </pre> </section> </div> <div class="part"> <section> <h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p> </section> </div> </div> <hr/> <div class="part"> <section> <h3>Sample Input 1</h3><pre>1000 8 1 3 4 5 6 7 8 9 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 1</h3><pre>2000 </pre> <p>She dislikes all digits except <var>0</var> and <var>2</var>.</p> <p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p> </section> </div> <hr/> <div class="part"> <section> <h3>Sample Input 2</h3><pre>9999 1 0 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 2</h3><pre>9999 </pre></section> </div> </span>
s658365704
p04045
Accepted
N,K=map(int,raw_input().split()) D=map(int,raw_input().split()) n=[0,1,2,3,4,5,6,7,8,9] a=[] #Allowed numbers for i in n: if i not in D: a.append(i) i=N while True: for j in D: if str(i).find(str(j))!=-1: break else: print str(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>
s145845445
p04045
Accepted
N, K = map(int, input().split()) D = input().split() for i in range(N, 100001): set_n = set(list(str(i))) for s in set_n: if s in D: break else: print(i) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s648834114
p04045
Accepted
[n, k] = map(int, raw_input().split()) d = raw_input().split() while True: ok = True for c in str(n): if c in d: ok = False break if ok: 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>
s107705127
p04045
Accepted
n, k = list(map(int, input().split(" "))) d = list(map(int, input().split(" "))) def valid(n): while n > 0: digit = n % 10 if digit in d: return False n = int(n / 10) return True for num in range(n, 10 * n): if valid(num): print(num) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; D_K≦9</var></li> <li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li> </ul> </section> </div> <hr/> <div class="io-style"> <div class="part"> <section> <h3>Input</h3><p>The input is given from Standard Input in the following format:</p> <pre><var>N</var> <var>K</var> <var>D_1</var> <var>D_2</var> … <var>D_K</var> </pre> </section> </div> <div class="part"> <section> <h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p> </section> </div> </div> <hr/> <div class="part"> <section> <h3>Sample Input 1</h3><pre>1000 8 1 3 4 5 6 7 8 9 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 1</h3><pre>2000 </pre> <p>She dislikes all digits except <var>0</var> and <var>2</var>.</p> <p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p> </section> </div> <hr/> <div class="part"> <section> <h3>Sample Input 2</h3><pre>9999 1 0 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 2</h3><pre>9999 </pre></section> </div> </span>
s044681363
p04045
Accepted
N, K = [int(n) for n in input().split()] D = set([int(n) for n in input().split()]) def digits(n): res = set() while n > 0: res = res.union(set([n%10])) n //= 10 return res for price in range(N, 10000000000000000): if digits(price).isdisjoint(D): print(price) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; D_K≦9</var></li> <li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li> </ul> </section> </div> <hr/> <div class="io-style"> <div class="part"> <section> <h3>Input</h3><p>The input is given from Standard Input in the following format:</p> <pre><var>N</var> <var>K</var> <var>D_1</var> <var>D_2</var> … <var>D_K</var> </pre> </section> </div> <div class="part"> <section> <h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p> </section> </div> </div> <hr/> <div class="part"> <section> <h3>Sample Input 1</h3><pre>1000 8 1 3 4 5 6 7 8 9 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 1</h3><pre>2000 </pre> <p>She dislikes all digits except <var>0</var> and <var>2</var>.</p> <p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p> </section> </div> <hr/> <div class="part"> <section> <h3>Sample Input 2</h3><pre>9999 1 0 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 2</h3><pre>9999 </pre></section> </div> </span>
s450434318
p04045
Accepted
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """042-c""" import sys def solve(dislike_digits_table, first_like_digit, N): """Solve.""" for i, _ in enumerate(N): c = N[i] while dislike_digits_table[int(c)]: if c == '9': if i == 0: return solve(dislike_digits_table, first_like_digit, '1' + '0' * len(N)) else: return solve(dislike_digits_table, first_like_digit, str(int(N[0:i+1]) + 1) + '0' * len(N[i+1:])) else: c = chr(ord(c) + 1) N = N[0:i] + c + '0' * len(N[i+1:]) return N def main(): """Main function.""" dislike_digits_table = [False for _ in range(10)] N, _ = sys.stdin.readline().split(' ') digits = map(int, sys.stdin.readline().split(' ')) for digit in digits: dislike_digits_table[digit] = True first_like_digit = str(next(i for i, v in enumerate(dislike_digits_table) if not v)) print(solve(dislike_digits_table, first_like_digit, N)) if __name__ == '__main__': sys.exit(main())
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s026895051
p04045
Accepted
import math a,b=(int(i) for i in input().split()) s=[int(i) for i in input().split()] n=[0,1,2,3,4,5,6,7,8,9] n1 = [val for val in n if val not in s] n1.sort() keta=int(math.log10(a) + 1) n_number=10-b aa=str(a) answer=[] OKANE1=0 OKANE2=0 OKANE3=0 OKANE4=0 OKANE5=0 for i in range(n_number+1): for j in range(n_number+1): for k in range(n_number+1): for l in range(n_number+1): for m in range(n_number): if i!=0: OKANE1=n1[i-1] if j!=0: OKANE2=n1[j-1] if k!=0: OKANE3=n1[k-1] if l!=0: OKANE4=n1[l-1] OKANE5=n1[m] OKANE=10000*OKANE1+1000*OKANE2+100*OKANE3+10*OKANE4+OKANE5 if a<=OKANE: answer.append(OKANE) print(min(answer))
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; D_K≦9</var></li> <li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li> </ul> </section> </div> <hr/> <div class="io-style"> <div class="part"> <section> <h3>Input</h3><p>The input is given from Standard Input in the following format:</p> <pre><var>N</var> <var>K</var> <var>D_1</var> <var>D_2</var> … <var>D_K</var> </pre> </section> </div> <div class="part"> <section> <h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p> </section> </div> </div> <hr/> <div class="part"> <section> <h3>Sample Input 1</h3><pre>1000 8 1 3 4 5 6 7 8 9 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 1</h3><pre>2000 </pre> <p>She dislikes all digits except <var>0</var> and <var>2</var>.</p> <p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p> </section> </div> <hr/> <div class="part"> <section> <h3>Sample Input 2</h3><pre>9999 1 0 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 2</h3><pre>9999 </pre></section> </div> </span>
s837344789
p04045
Accepted
import sys N,K = list(map(int,input().split())) D = input().split() while True: breaked = False for i in range(len(str(N))): if str(N)[i] in D: breaked = True break if not(breaked): print(N) sys.exit() N += 1
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s464037232
p04045
Accepted
n, k = map(int, raw_input().strip().split()) l = map(int, raw_input().strip().split()) ls = [] for x in l: ls.append(str(x)) def has_string(ns): r = True for x in ls: if x not in ns: pass else: r = False return r while n < 100000: ns = str(n) if has_string(ns): print(ns) exit() 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>
s649714775
p04045
Accepted
N, K = map(int, input().split()) D = list(map(int, input().split())) L = [i for i in range(10) if i not in D] A = [] for i in L: A.append(i) for i in L: for j in L: A.append(10*i+j) for i in L: for j in L: for k in L: A.append(100*i+10*j+k) for i in L: for j in L: for k in L: for l in L: A.append(1000*i+100*j+10*k+l) for i in L: for j in L: for k in L: for l in L: for m in L: A.append(\ 10000*i+1000*j+100*k+10*l+m) for i in A: if i >= N: print(i) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s986285125
p04045
Accepted
from itertools import count def main(): N, K = map(int, input().split()) D_list = list(input().split()) for c in count(N): c = str(c) for d in D_list: if d in c: break else: print(c) 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>
s043307632
p04045
Accepted
N, K = list(map(int, input().split(" "))) D = list(map(str, input().split(" "))) ans = N while(1): j = True for d in D: if d in str(ans): j = False break if j == True: 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>
s750636850
p04045
Accepted
nums = [int(x) for x in input().split()] N,K = nums[0],nums[1] D = set([int(x) for x in input().split()]) ans = N def solve(M): M = [int(x) for x in str(M)] for m in M: if m in D: return False return True while(1): if solve(ans): print(ans) break else: ans +=1
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; D_K≦9</var></li> <li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li> </ul> </section> </div> <hr/> <div class="io-style"> <div class="part"> <section> <h3>Input</h3><p>The input is given from Standard Input in the following format:</p> <pre><var>N</var> <var>K</var> <var>D_1</var> <var>D_2</var> … <var>D_K</var> </pre> </section> </div> <div class="part"> <section> <h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p> </section> </div> </div> <hr/> <div class="part"> <section> <h3>Sample Input 1</h3><pre>1000 8 1 3 4 5 6 7 8 9 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 1</h3><pre>2000 </pre> <p>She dislikes all digits except <var>0</var> and <var>2</var>.</p> <p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p> </section> </div> <hr/> <div class="part"> <section> <h3>Sample Input 2</h3><pre>9999 1 0 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 2</h3><pre>9999 </pre></section> </div> </span>
s844510754
p04045
Accepted
N, K = map(int, input().split()) D = list(map(str,input().split())) ans = N while sum([d in str(ans) for d in D]): 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>
s515963656
p04045
Accepted
a, _ = map(int, raw_input().split()) b = "".join(raw_input().split()) b = set(b) for i in xrange(a, 99999999): if b.isdisjoint(str(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>
s566473380
p04045
Accepted
N,K = map(int, raw_input().split()) dislike = raw_input().split() like = [str(n) for n in range(10) if str(n) not in dislike] for n in range (N,100000): for d in str(n): if d in dislike: 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>
s292200461
p04045
Accepted
N, K = map(int, raw_input().split()) D = map(int, raw_input().split()) W = filter(lambda x: not x in D, range(10)) def dfs(x): if x >= N: return x return min([dfs(10*x + d) for d in W]) print min([dfs(i) for i in W if (i > 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>
s120728340
p04045
Accepted
def isValid(n,l): s = str(n) for c in s: if c in l: return False return True n,k = map(int, raw_input().split()) dls = raw_input().split() for i in range(n,100000): if isValid(i,dls): 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>
s687109847
p04045
Accepted
# -*- coding: utf-8 -*- n,k = map(int,raw_input().split()) d = map(int,raw_input().split()) flg = 1 num = n-1 while(flg): num += 1 strnum = str(num) check = [strnum.find(str(i))+1 for i in d] flg = sum(check) print(num)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s727651488
p04045
Accepted
N,K = map(int,input().split()) D = list(map(int,input().split())) for i in range(N*10): n = str(N + i) ok = True for j in D: if n.find(str(j)) != -1: ok = False break if ok: 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>
s823272035
p04045
Accepted
import sys def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None def solve(): N, K = map(int, input().split()) D = [str(i) for i in input().split()] ans = 0 for m in range(N, 10**6): if canbuy(N, D, m): ans = m break print(m) def canbuy(N, D, m): m = str(m) for d in D: if m.find(str(d)) != -1: return False return True if __name__ == '__main__': solve()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &lt; 10000</var></li> <li><var> 1 ≦ K &lt; 10</var></li> <li><var> 0 ≦ D_1 &lt; D_2 &lt; … &lt; D_K≦9</var></li> <li><var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var></li> </ul> </section> </div> <hr/> <div class="io-style"> <div class="part"> <section> <h3>Input</h3><p>The input is given from Standard Input in the following format:</p> <pre><var>N</var> <var>K</var> <var>D_1</var> <var>D_2</var> … <var>D_K</var> </pre> </section> </div> <div class="part"> <section> <h3>Output</h3><p>Print the amount of money that Iroha will hand to the cashier.</p> </section> </div> </div> <hr/> <div class="part"> <section> <h3>Sample Input 1</h3><pre>1000 8 1 3 4 5 6 7 8 9 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 1</h3><pre>2000 </pre> <p>She dislikes all digits except <var>0</var> and <var>2</var>.</p> <p>The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.</p> </section> </div> <hr/> <div class="part"> <section> <h3>Sample Input 2</h3><pre>9999 1 0 </pre> </section> </div> <div class="part"> <section> <h3>Sample Output 2</h3><pre>9999 </pre></section> </div> </span>
s440170617
p04045
Accepted
import itertools a=set([0,1,2,3,4,5,6,7,8,9]) n,_=map(int,input().split()) b=map(int,input().split()) l=len(str(n)) c=set(b)^a for i in range(l,l+2): for x in itertools.product(c,repeat=i): d=''.join(map(str,x)) if int(d)>=n:print(d);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>
s469971544
p04045
Accepted
from itertools import product N, K = [int(_) for _ in input().split()] D = set([int(_) for _ in input().split()]) valid = list(set(range(10)) - D) x = set() for r in range(1,6): for p in product(valid, repeat=r): x.add(int(''.join([str(i) for i in p]))) for n in sorted(x): if n >= N: print(n) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s235004213
p04045
Accepted
n, k = map(int, input().split()) dislikes = list(map(int, input().split())) m = n while True: m = list(str(m)) l = [] for p in m: if int(p) not in dislikes: l.append(p) continue else: m = int(''.join(m))+1 break if len(l) >= len(str(n)): if int(''.join(l))>=n: break print(''.join(m))
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s180779735
p04045
Accepted
def run_code(N, K, ds): dislike_digits_set = set(i for i in ds) avail_digits = [i for i in range(10) if i not in dislike_digits_set] avail_min = avail_digits[0] def get_next_digit(d): last = 10 for ad in (avail_digits + [last]): if ad >= d: if ad == last: return (1, avail_min) else: return (0, ad) def fill_last_kth_digits(n_digits, d, k): n = len(n_digits) for i in range(k): n_digits[n - i - 1] = d return n_digits def to_num(n_digits): num = 0 n = len(n_digits) for i in range(n): num += n_digits[i] * 10**(n-i-1) return num def to_digits(num): return [int(i) for i in str(num)] def search_nearest_larger(num): n_digits = to_digits(num) n = len(n_digits) for i in range(n): d_in = n_digits[i] inc, d_out = get_next_digit(d_in) if inc == 0 and d_in == d_out: continue if inc > 0: num += 10**(n-i) n_digits = fill_last_kth_digits(to_digits(num), avail_min, n-i) return search_nearest_larger(to_num(n_digits)) else: n_digits[i] = d_out return to_num(fill_last_kth_digits(n_digits, avail_min, n-i-1)) return to_num(n_digits) return search_nearest_larger(N) N, K = [int(i) for i in input().split()] ds = [int(i) for i in input().split()] res = run_code(N, K, ds) 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>
s671202563
p04045
Accepted
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 def LI(): return list(map(int, input().split())) def II(): return int(input()) def LS(): return input().split() def S(): return input() def main(): n,k = LI() s = set(LS()) for i in range(n,n*100): t = set(_ for _ in str(i)) if not (t & s): return i return 0 print(main())
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).</p> <p>However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.</p> <p>Find the amount of money that she will hand to the cashier.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var> 1 ≦ N &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>
s063343244
p04045
Accepted
N, K = map(int, raw_input().split()) D = set(raw_input().split()) for i in xrange(N, 100000+1): if set(str(i)) & D == set(): 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>
s431790064
p04045
Accepted
n,k=[int(i) for i in input().split()] d=[int(i) for i in input().split()] def check(num): for i in range(len(num)): for j in d: if int(num[i])==j: return False return True while(not check(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>
s618853722
p04045
Accepted
# coding: utf-8; def main(): num = [0,1,2,3,4,5,6,7,8,9] n, k = map(int, input().split()) d = list(map(int, input().split())) usable_num = list(set(num) - set(d)) while True: f = True for a in str(n): if int(a) not in usable_num: f = False break if f: 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>
s192324944
p04045
Accepted
# coding: utf-8; def main(): num = [0,1,2,3,4,5,6,7,8,9] n, k = map(int, input().split()) d = list(map(int, input().split())) usable_num = list(set(num) - set(d)) while True: if len(set(map(int, str(n))) - set(usable_num)) == 0: break else: 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>
s127921814
p04045
Accepted
from collections import defaultdict from itertools import combinations def func(i, d, now, use, st): if i >= d: st.append(now) return for x in use: func(i + 1, d, now + str(x), use, st) def solve(): n, k = map(int, input().split()) d = list(map(int, input().split())) use = [] for i in range(10): if i not in d: use.append(i) for i in range(len(str(n)), len(str(n)) + 2): st = [] func(0, i, "", use, st) for x in sorted(st): if int(x) >= n: return x def main(): print(solve()) 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>
s436959440
p04045
Accepted
n,k=map(int,raw_input().split()) d=set(map(int,raw_input().split())) chk=set([str(i) for i in range(10) if i not in d]) while 1: tmp=set(str(n)) if len(tmp&chk)==len(tmp): 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>
s284598641
p04045
Accepted
n, k = map(int, input().split()) d = [int(i) for i in input().split()] ablenum = [int(i) for i in range(10)] lis_n = str(n) lis_n = list(lis_n) #print(lis_n) # 使用可能な数一覧 for i in d: ablenum.remove(i) #print(ablenum) flag_bigdigit = -1 # max(ablenum)より大きい桁があるかどうか for i in range(len(lis_n)): _i = len(lis_n) - i - 1 if(int(lis_n[_i]) > max(ablenum)): flag_bigdigit = _i break # max(ablenum)より大きい桁があれば if(flag_bigdigit != -1): flag_increaseDights = 1 # 桁を増やす必要があるかどうか確認 for i in range(flag_bigdigit-1, 0): # nの桁より大きい数字がablenumに存在していれば桁を増やす必要はない if(int(lis_n[i]) < max(ablenum)): flag_increaseDights = 0 break else: flag_increaseDights = 0 #print("bigdigit:{0} increace:{1}".format(flag_bigdigit, flag_increaseDights)) ans = "" # 桁を増やす必要があるならば if(flag_increaseDights == 1): for i in range(len(lis_n)+1): # 一桁目は0以外の最も小さな数 if(i == 0): mnum = min(ablenum) if(mnum == 0): mnum = ablenum[1] ans += str(mnum) # 2桁目以降は最も小さい数 else: mnum = min(ablenum) ans += str(mnum) # 桁を増やす必要がなければ、各桁の数字以上の最も小さい数を使う else: flag_over = 0 for i in range(len(lis_n)): if(flag_over == 0): mnum = min(ablenum) # その桁以上の数になるまで大きくする j = 0 while mnum < int(lis_n[i]): #print("mnum:{0} j:{1}".format(mnum, j)) j += 1 mnum = ablenum[j] if(mnum > int(lis_n[i])): flag_over = 1 ans += str(mnum) else: mnum = min(ablenum) ans += str(mnum) 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>
s789637562
p04045
Accepted
import sys N, K = map(int, sys.stdin.readline().split()) D = map(int, sys.stdin.readline().split()) for i in xrange(N * 10): if i >= N: temp = i isCorrect = True while temp > 0: if (temp % 10) in D: isCorrect = False break else: temp /= 10 if isCorrect: 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>
s661000810
p04045
Accepted
n,k=map(int,raw_input().split()) d=[i for i in raw_input().split()] while True: f=True for i in d: if i in str(n): f=False break if f: 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>
s901455089
p04045
Accepted
n,k=map(int,input().split()) d=[i for i in input().split()] while True: f=True for i in d: if i in str(n): f=False break if f: 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>