Problem:
Score : 200 points

Problem Statement

An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.

Given an integer N, determine whether it is a Harshad number.

Constraints

1?N?10^8

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print Yes if N is a Harshad number; print No otherwise.

Sample Input 1

12

Sample Output 1

Yes

f(12)=1+2=3. Since 12 is divisible by 3, 12 is a Harshad number.

Sample Input 2

57

Sample Output 2

No

f(57)=5+7=12. Since 57 is not divisible by 12, 12 is not a Harshad number.

Sample Input 3

148

Sample Output 3

No

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <stack>

typedef long long ll;
typedef std::vector< int > VI;

const double EPS = 1e-10;
const double PI  = acos(-1);
const ll     INF = 1 << 30;

ll gdb_exec(ll a, ll b) {
  if (b == 0) return a;
  return gdb_exec(b, a % b);
}

ll gdb(ll a, ll b) {
  if (a < b) std::swap(a, b);
  if (a == 0 || b == 0) return -999999999;
  return gdb_exec(a, b);
}

ll lcm(ll a, ll b) {
  ll gdb_val = gdb(a, b);
  if (a % gdb_val == 0) {
    return (a / gdb_val) * b;
  }
  return (b / gdb_val) * a;
}

int main(int argc, char* argv[])
{
  ll val;
  std::string s;
  std::string::iterator it;

  std::cin >> s;
  sscanf(s.c_str(), "%lld", &val);

  ll sum = 0;
  for (it = s.begin(); it != s.end(); it++) {
    sum += *it - '0';
  }

  if (val % sum == 0) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}