Problem:
Score : 200 points

Problem Statement

Let S(n) denote the sum of the digits in the decimal notation of n.
For example, S(101) = 1 + 0 + 1 = 2.

Given an integer N, determine if S(N) divides N.

Constraints

1 \leq N \leq 10^9

Input

Input is given from Standard Input in the following format:

N

Output

If S(N) divides N, print Yes; if it does not, print No.

Sample Input 1

12

Sample Output 1

Yes

In this input, N=12.
As S(12) = 1 + 2 = 3, S(N) divides N.

Sample Input 2

101

Sample Output 2

No

As S(101) = 1 + 0 + 1 = 2, S(N) does not divide N.

Sample Input 3

999999999

Sample Output 3

Yes

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

/*
AtCoder Beginner Contest 101 B - Digit Sums
結果:
*/

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

#define max(x,y)(x<y?y:x)
#define int long long

int compare(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

//尺取法
//scanf("%d", &N);
//for (i; i < N; ++i) {
//	scanf("%d", &A[i]);
//	if (b[A[i]] == 1) {
//		ans = max(ans, i - j);
//		while (b[A[i]] == 1) {
//			b[A[j++]] = 0;
//		}
//	}
//	b[A[i]] = 1;
//}
//ans = max(ans, i - j);
//printf("%d\n", ans);

//文字列の最大出現
//static int N, i, j, ans;
//static int A, B;
//static char A[50][51];
//static int cnt, max;
//char *max_name;
//
//scanf("%d", &N);
//for (i = 0; i < N; i++) {
//	scanf("%s", A[i]);
//}
//max_name = A[0];
//for (i = 0; i < N; i++) {
//	cnt = 0;
//	for (j = 0; j < N; j++) {
//		if (strcmp(A[i], A[j]) == 0) {
//			cnt++;
//		}
//		if (cnt > max) {
//			max = cnt;
//			max_name = A[i];
//		}
//	}
//}
//printf("%s\n", max_name);

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF

int main() {
	//static int N, i, j, ans;
	static int A, B,D, i = 0, j = 0, digit = 0, cnt = 0, ans = 0;
	//static int A, B;
	//static int A, B, C;
	static int c[10] = { 0 };
	//static char A[50][51];
	//static int cnt, max;
	//char *max_name;
	//static int ans;
	scanf("%d", &A);
	B = A;
	D = A;
	while (A != 0) {
		A = A / 10;
		++digit;
	}
	i = digit - 1;
	while (i != -1) {
		c[j] = B / pow(10, i);
		B = B - (c[j] * pow(10, i));
		cnt = cnt + c[j];
		i--;
		j++;
	}
	if( D%cnt==0 ){ printf("%s\n", "Yes"); }
	else{ printf("%s\n", "No"); }


	//ans = 0;
	//qsort(A, N, sizeof(int), compare);

	//ans = ;
	//printf("%d\n", ans);
	//printf("%s\n", max_name);

#ifdef DEBUGF
	getch();
#endif
	return 0;
}