In c++
#include
#include
using namespace std;
int main(){
int t;
cin>>t;
while(t–){
int n;
cin>>n;
vector ans;
int t=n;
while(t){
if(t%10!=0) ans.push_back(t%10);
t=t/10;
}
int cnt=0;
for(int i=0;i<ans.size();i++){
if(n%ans[i]==0) cnt++;
}
cout<<cnt<<endl;
}
}
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println(“Enter number of test cases”);
int t = sc.nextInt();
int[] arr = new int[t];
System.out.println(“Enter “+t+” numbers”);
for (int i = 0; i < arr.length; i++) {
arr[i]=sc.nextInt();
}
the input and output does not come in the format that is stated in the question. it rather comes like this:
2 //test case-input
12 //first integer-input
2 //output for first integer
1012 //second integer-input
3 // output for second integer
In c++
#include
#include
using namespace std;
int main(){
int t;
cin>>t;
while(t–){
int n;
cin>>n;
vector ans;
int t=n;
while(t){
if(t%10!=0) ans.push_back(t%10);
t=t/10;
}
int cnt=0;
for(int i=0;i<ans.size();i++){
if(n%ans[i]==0) cnt++;
}
cout<<cnt<<endl;
}
}
#include
using namespace std;
int main()
{
int t;
cin >> t;
int n;
for (int i = 1; i > n;
int count = 0;
int q = n;
while (n > 0)
{
int p = n % 10;
if (p != 0)
{
if (q % p == 0)
{
count++;
}
}
n = n / 10;
}
cout << count << endl;
}
return 0;
}
#include
using namespace std;
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
int main()
{
#ifndef ONLINE_JUDGE
ifstream cin(“input.txt”);
ofstream cout(“output.txt”);
#endif
fastio;
int T,n;
int count=0;
cin >> T;
while(T–){
cin >> n ;
int m = n;
count =0;
while(n!=0){
int a=n% 10;
if(a && m%a==0){
count++;
}
n=n/10;
}
cout << count << "\n";
}
return 0;
}
#include
typedef long long ll;
using namespace std;
int main()
{
ll n,i,j,k,b[100],rep;
cin>>n;
ll a[n];
for(i=0;i>a[i];
for(i=0;i=0;j–){
if(a[i]%b[j]==0 && b[j]!=0)
rep++;
}
cout<<rep<<endl;
}
return 0;
}
import java.util.Scanner;
public class DivisorOfdigitsOfNum
{
public static void main(String[] args)
{
Scanner sc= new Scanner(System.in);
int test= sc.nextInt();
while(test>=1)
{
int n= sc.nextInt();
int dup=n;
int count=0;
while(dup>0)
{
int rem= dup%10;
if(rem!=0)
{
if(n%rem==0 )
count++;
}
dup=dup/10;
}
System.out.println(count);
test–;
}
}
}
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println(“Enter number of test cases”);
int t = sc.nextInt();
int[] arr = new int[t];
System.out.println(“Enter “+t+” numbers”);
for (int i = 0; i < arr.length; i++) {
arr[i]=sc.nextInt();
}
for (int i = 0; i 0) {
int temp = num%10;
if (temp!=0 && arr[i]%temp==0) {
count++;
}
num=num/10;
}
System.out.println(count);
}
}
}
the input and output does not come in the format that is stated in the question. it rather comes like this:
2 //test case-input
12 //first integer-input
2 //output for first integer
1012 //second integer-input
3 // output for second integer
How can we get the output as stated?
try this
#include
typedef long long ll;
using namespace std;
int main()
{
ll n,i,j,k,b[100],rep;
cin>>n;
ll a[n];
for(i=0;i>a[i];
for(i=0;i=0;j–){
if(a[i]%b[j]==0 && b[j]!=0)
rep++;
}
cout<<rep<<endl;
}
return 0;
}
#include
int main(){
int i,t,copy,count,k;
scanf(“%d”,&t);
int n[t],x[10000];
for(i=0;i<t;i++){
scanf("%d",&n[i]);
}
for(i=0;i<t;i++){
k=0;
count = 0;
copy = n[i];
while(n[i]!=0){
x[k] = n[i]%10;
n[i] = n[i]/10;
if(x[k]==0){
k–;
continue;
}
if(copy%x[k]==0){
count++;
}
k++;
}
printf("%d\n",count);
}
return 0;
}