PUCMM025 - Divisor Digits

Given a number, output how many digits of that number the number is itself divisible by. Count all occurrences of such digits in the number, not just the first.

For example, 12345 is divisible by 1, 3, and 5, so, the answer in this case must be 3.

Input

Each test case is a number between 1 and 10240.

Output

for each test case, output how many of its digits divide the number.

Example

Input:
12345
661232
312
730000000

Output:
3
3
3
0

Added by:Olson Ortiz
Date:2011-12-08
Time limit:0.207s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C CSHARP C++ 4.3.2 CPP JAVA
Resource:Used in 2da Olimpiada de Programacion PUCMM-ACM-ISC (fase 2)

hide comments
2015-05-28 12:01:56 Rishabh Joshi
string data type will give TLE due to slower input output (as dynamic mem allocation is involved) suggested using char[] and scanf/printf.
2015-05-27 22:08:33 Arnab Mitra
Easy if you can figure out a way to deal with divisibility with 7
2015-02-11 11:28:54 Raj Kumar Chauhan
killing lot of time , problem is with 7 . and also do care of variables.
2015-01-18 11:13:01 lovecode
only issue is with 7 otherwise easy.........
2015-01-13 15:10:38 Ash
all those getting WA try running your code for for small prime multiples of seven
2014-07-08 17:03:13 Ranjan Kumar Singh
just do it!!!
2014-05-10 13:08:02 ivar.raknahs
getting WA again and again
any tricky test cases :(
id=11549920

Last edit: 2014-05-10 13:14:31
2014-05-09 19:48:28 agaurav77
Focus on EOF and divisibility rules.
2014-04-19 12:44:10 Unknown
150 on SPOJ !!!
2014-03-07 15:39:41 GOKU
wrong answer why!!!!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.