Given a positive integer N. Write a program to find count of digits of the number which evenly divides the number N.
Input:
First line of input of contains a single integer T which denotes the number of test cases. T test cases follows. First line of each test cases contains a single integer N.
Output:
For each test case print the count of all those digits in N which evenly divides N.
Constraints:
1<=T<=100
1<=N<=106
Example:
Input:
2
12
1012
Output:
2
3
First line of input of contains a single integer T which denotes the number of test cases. T test cases follows. First line of each test cases contains a single integer N.
Output:
For each test case print the count of all those digits in N which evenly divides N.
Constraints:
1<=T<=100
1<=N<=106
Example:
Input:
2
12
1012
Output:
2
3
Get Your Code
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int x=n;
int num=0;
while(n!=0)
{
int digit=n%10;
n=n/10;
if(digit!=0)
{
if(x%digit==0)
{
num++;
}
}
}
cout<<num<<endl;
}
}