The Alchemist and Weird Functions

0

0 votes
Medium
Problem

Given N natural numbers a1,a2....aN and two weird functions f(x) and g(x).

g(x)= sum of digits of x

f(x)=1+(xi=1g(ai))%9g(xi=1ai)%9 if x % (kk)=0, kN and k1

f(x)=0 otherwise.

Your task is to find the value of Ni=1f(i)

Input:

First line of input contains a single integer N

Next N lines contains the natural numbers a1,a2,..aN

Output:

Output a single integer containing the required answer.

Constraints:

1N2107

1ai1010000

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?