Problem: Contest Page | CodeChef
DIFFICULTY:
EASY.
PROBLEM:
Chef has a natural number N. Cheffina challenges chef to check whether the given number is divisible by the sum of its digits or not. If the given number is divisible then print “Yes” else “No”.
Program:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int sum,t,x,n;
cin>>t;
while(t--){
cin>>n;
x=n;
sum=0;
while(n>0){
sum+=n%10;
n=n/10;
}
if(x%sum)cout<<"No\n";
else cout<<"Yes\n";
}
}