Logo
(追記) (追記ここまで)

26870번 - Hidden Digits 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 1024 MB349466.667%

문제

You are given a sequence of $n$ digits $d_0,ドル $d_1,ドル \dots $d_{n - 1}$. Find the minimum positive integer $x$ such that for all 0ドル \le i < n,ドル the decimal representation of number $x + i$ contains the digit $d_i$.

입력

Each test contains multiple test cases. The first line contains the number of test cases $t$ (1ドル \le t \le 10^5$). The description of the test cases follows.

The first line of each test case contains a single integer $n$ (1ドル \le n \le 10^6$).

The second line contains a string of $n$ digits $d_0 d_1 \ldots d_{n-1}$ (0ドル \le d_i \le 9$).

It is guaranteed that the sum of $n$ over all test cases does not exceed 10ドル^6$.

출력

For each test case, print a single integer $x$ --- the smallest positive integer such that the decimal representation of $x+i$ contains the digit $d_i$ for all 0ドル \le i < n$.

제한

예제 입력 1

6
5
12345
5
01234
3
239
9
998244353
10
1000000007
20
18446744073709551616

예제 출력 1

1
10
92
45296
701
10367486

힌트

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > ICPC 2022-2023 North-Western Russia Regional Contest H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /