## Problem: Find Digits

Problem Statement

Given a number you have to print how many digits in that number exactly divides that number.

Input format

The first line contains T (number of test cases followed by t lines each containing n

Constraints
1 <=T <= 15
0 < N < 1010

Output Format
Number of digits in that number exactly divides that number.

Input

``````1
12
``````

Output

``````2
``````

Explanation
2 digits in the number “12” divide the number exactly. “1” divides 12 exactly in 12 parts, and “2” divides 12 equally in 6 parts.

This challenge was a part of Pragyan 12

This is my method:

#include <stdio.h>

long Count(long n);

int main(){
int T;
scanf(“%d”,&T);
long a[T];
for(int i=0;i<T;++i)
scanf(“%ld”,&a[i]);
for(int i=0;i<T;++i){
printf(“%ld”,Count(a[i]));
if(i!=T-1)
printf(“\n”);
}
return 0;
}

long Count(long n){
register long i;
long Sum=0,k=n,temp;
do{
temp=n%10;
if(temp!=0)
if(k%temp==0)
Sum++;
n/=10;
if(n/10==0){
temp=n%10;
if(temp!=0)
if(k%temp==0)
Sum++;
}
}while(n/10!=0);
return Sum;
}

Advertisements