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

9565번 - Identify the Number 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 128 MB324327.273%

문제

You are given three numbers N, Q and R. You want to find M, such that:

  • M is positive.
  • The string decimal representation of M is a subsequence of the string decimal representation of N, i.e. M can be obtained from the removal of zero or more digits from the decimal representation of N.
  • M gives a remainder of R when divided by Q.
  • M is the maximum possible.

입력

Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1 ≤ T ≤ 200). Next T lines contain the test cases, each on a single line.

Each case contains three integers, separated by single spaces, N, R, Q as described in the problem, in this order (1 ≤ N < 101,000, 0 ≤ R < Q ≤ 1, 000). All numbers in the input will not contain leading zeros.

출력

For each test case, output, on a single line, the number M as described in the problem, with no leading zeros. If no such M can be found, output on a single line "Not found" instead.

제한

예제 입력 1

3
840 0 8
901 3 8
123456789 10 100

예제 출력 1

840
91
Not found

힌트

In the first case, 840 is divisible by 8, thus it is the largest possible value of M.

In the second case, the subsequences of 901 are {9, 0, 1, 90, 01, 91, 901}. Out of these there is 0 which is not positive and 01 which has a leading zero. Only 91 has a remainder of 3 when divided by 8.

In the third case, there is no subsequence of 123456789 that gives a remainder of 10 when divided by 100.

출처

ICPC > Regionals > Africa and Arab > Arab Collegiate Programming Contest > 2011 Arab Collegiate Programming Contest I번

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

출처

대학교 대회

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

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