forked from alexprut/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
32 lines (28 loc) · 712 Bytes
/
Solution.java
File metadata and controls
32 lines (28 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
static int findDigits(int n) {
String number = "" + n;
int counter = 0;
for (int i = 0; i < number.length(); i++) {
int tmp = Character.getNumericValue(number.charAt(i));
if (tmp != 0) {
counter = (n % tmp == 0) ? counter + 1 : counter;
}
}
return counter;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for (int a0 = 0; a0 < t; a0++) {
int n = in.nextInt();
int result = findDigits(n);
System.out.println(result);
}
in.close();
}
}