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

8397번 - Byteland Lottery 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB58231836.735%

문제

One of the most popular games organized by Byteland Lottery is "Huge blend". The rules of this game are simple. From the container with a fixed number of balls in it (each of them has a natural number assigned), some number of balls are chosen. In the next step the product of all numbers from the chosen balls is calculated. That product is the winning number. The person who guesses the right number wins the main prize. Before the drawing, it is known how many balls will take part in it. The numbers written on the balls are also known. It is not known however, how many balls will be selected - maybe all of them, or maybe only one.

ByteGuy always wanted to win "Huge blend", however years of fruitless attempts caused that he started to wonder about the chances of winning. He decided to count the number n - the sum of all possible results of draws. Unfortunately, ByteGuy's computer overheated during calculations, so he asked you to help him calculate something simpler - the value of F(n), where F is a function defined as follows:

  • F(k) = k, k ≤ 9
  • F(k) = F(the sum of all digits of k), k ≥ 10

For example: F(9) = 9, F(123) = 6, F(9876) = F(30) = 3.

Write a program which:

  • reads from the standard input the number l (the number of balls taking part in a draw) and l natural numbers w1, w2, ..., wl (numbers printed on the balls),
  • computes the value of F(n), where n is the sum of all possible results of draws,
  • writes the answer to the standard output.

입력

The first line of the standard input contains a natural number l - the number of balls taking part in a draw, 1 ≤ l ≤ 106. In the second line there are l natural numbers wm, 0 ≤ wm ≤ 108 - numbers written on the balls. They are separated with single spaces.

출력

One integer is to be written to the standard output. This integer should be the value of F(n).

제한

예제 입력 1

3
10 13 12

예제 출력 1

3

힌트

출처

Contest > Algorithmic Engagements > PA 2006 3-1번

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

출처

대학교 대회

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

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