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

23952번 - Elevanagram 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
20 초 (추가 시간 없음) 1024 MB977100.000%

문제

It is a well known fact that a number is divisible by 11 if and only if the alternating sum of its digits is equal to 0 modulo 11. For example, 8174958 is a multiple of 11, since 8 -ひく 1 +たす 7 -ひく 4 +たす 9 -ひく 5 +たす 8 = 22.

Given a number that consists of digits from 1-9, can you rearrange the digits to create a number that is divisible by 11?

Since the number might be quite large, you are given integers A1, A2, ..., A9. There are Ai digits i in the number, for all i.

입력

The first line of the input gives the number of test cases, T. T lines follow. Each line contains the nine integers A1, A2, ..., A9.

출력

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is YES if the digits can be rearranged to create a multiple of 11, and NO otherwise.

제한

  • 1 ≤ T ≤ 100.
  • 1 ≤ A1 + A2 + ... + A9.

Test Set 1 (20점)

  • 0 ≤ Ai ≤ 20, for all i.

Test Set 2 (27점)

  • 0 ≤ Ai ≤ 109, for all i.

예제 입력 1

6
0 0 2 0 0 1 0 0 0
0 0 0 0 0 0 0 0 12
0 0 0 0 2 0 1 1 0
3 1 1 1 0 0 0 0 0
3 0 0 0 0 0 3 0 2
0 0 0 0 0 0 0 1 0

예제 출력 1

Case #1: YES
Case #2: YES
Case #3: NO
Case #4: YES
Case #5: YES
Case #6: NO

힌트

  • In Sample Case #1, the digits are 336, which can be rearranged to 363. This is a multiple of 11 since 3 - 6 + 3 = 0.
  • In Sample Case #2, the digits are 999999999999, which is already a multiple of 11, since 9 - 9 + 9 - 9 + ... - 9 = 0.
  • In Sample Case #3, the digits are 5578, which cannot be rearranged to form a multiple of 11.
  • In Sample Case #4, the digits are 111234, which can be rearranged to 142131. This is a multiple of 11 since 1 -ひく 4 +たす 2 -ひく 1 +たす 3 -ひく 1 = 0.
  • In Sample Case #5, the digits are 11177799, which can be rearranged to 19191777. This is a multiple of 11 since 1 -ひく 9 +たす 1 -ひく 9 +たす 1 -ひく 7 +たす 7 -ひく 7 = -ひく22 (which is 0 modulo 11).
  • In Sample Case #6, the only digit is 8, which cannot be rearranged to form a multiple of 11.

출처

Contest > Google > Kick Start > Google Kick Start 2019 > Round H C번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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