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

30141번 - Soccer Teams 다국어

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

문제

My kid's favorite subject is math, as you know by now. He is learning division now, and his teacher has taught him about even numbers being divisible by 2, numbers whose digits add up to a multiple of 3 being exactly divisible by 3 etc.

He was familiar with division by 11 during selection for soccer teams on his playground, and was wondering whether there was any easy rule to see if a number was divisible by 11. For example, he wondered, if he arranged a number of digits 0-9 in a row to form a number, which ones would be divisible by 11?

He decided to start off with d[1] 1's, d[2] 2's ..., d[9] 9's, and seeing what is the minimum multiple of 11 that he could get by using all these digits, together with any number of 0's. Please help him figure out how many digits there are in this minimum multiple.

입력

The first line will contain the number of test cases T. T lines follow one corresponding to each test case. Each line has 9 integers d[1],...,d[9].

출력

Output T lines one corresponding to each test case. The ith line should contain the required answer for the corresponding test case. If he will not be able to form a multiple of 11 in this way, print -1.

제한

  • 1 ≤ T ≤ 100
  • 1 ≤ d[1] + ... + d[9] ≤ 100

예제 입력 1

2
2 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 1

예제 출력 1

2
3

힌트

For the first case, the number 11 can be formed which has 2 digits.

For the second case, number 209 can be formed which is divisible by 11 and has 3 digits.

출처

ICPC > Regionals > Asia West Continent > India > The 2010 ACM-ICPC Asia Amritapuri Regional Contest D번

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

출처

대학교 대회

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

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