AtCoder Beginner Contest 080 - Harshad Number

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-----
12

-----Sample Output-----
Yes

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

Source: atcoder | Difficulty: EASY


Solutions:
x = input()
s = sum(map(int, x))
print('Yes' if int(x) % s == 0 else 'No')


n = int(input())
x = eval('+'.join(str(n)))
print('Yes' if n % x == 0 else 'No')


n = int(input())
print('No' if n % sum([int(i) for i in str(n)]) else 'Yes')


n = int(input())
print('Yes' if n % sum(map(int, str(n))) == 0 else 'No')


n = input()
k = sum([int(c) for c in n])
print('Yes' if int(n) % k == 0 else 'No')


n = int(input())
flag = 0
n_str = str(n)
n_len = len(n_str)
n_digit = 0
for i in range(n_len):
	n_digit += int(n_str[i])
if n % n_digit == 0:
	flag = 1
if flag:
	print('Yes')
else:
	print('No')


def d(num):
	l = [int(x) for x in str(num)]
	return sum(l)
n = int(input())
print('Yes' if n % d(n) == 0 else 'No')


X = input()
print('Yes' if int(X) % sum(map(int, X)) == 0 else 'No')


n = input()
ans = 'Yes' if int(n) % sum(map(int, n)) == 0 else 'No'
print(ans)


n = str(input())
a = []
for i in n:
	a.append(int(i))
b = sum(a)
if int(n) % b == 0:
	print('Yes')
else:
	print('No')


N = int(input())
print('Yes' if N % sum(map(int, str(N))) == 0 else 'No')


n = input()
A = list(map(int, n))
print('Yes' if int(n) % sum(A) == 0 else 'No')


x = input()
a = [int(c) for c in x]
print('Yes' if int(x) % sum(a) == 0 else 'No')


n = int(input())
w = n
s = 0
while w > 0:
	s += w % 10
	w //= 10
print(('No', 'Yes')[n % s == 0])


n = input()
sum_index = 0
for i in n:
	sum_index += int(i)
if int(n) % sum_index == 0:
	print('Yes')
else:
	print('No')


n = input()

def f(x):
	return sum(list(map(int, list(n))))
if int(n) % f(n) == 0:
	print('Yes')
else:
	print('No')


x = int(input())
print('Yes' if x % sum(map(int, str(x))) == 0 else 'No')


n = input()
print(['No', 'Yes'][int(int(n) % sum([int(x) for x in n]) == 0)])


N = input()
f = 0
for num in N:
	f += int(num)
print('Yes' if int(N) % f == 0 else 'No')


N = input()
fN = sum(map(int, N))
print('Yes' if int(N) % fN == 0 else 'No')


N = str(input())
f = 0
for i in range(len(N)):
	f = f + int(N[i])
if int(N) % f == 0:
	print('Yes')
else:
	print('No')


N = input()
print('Yes' if int(N) % sum([int(i) for i in N]) == 0 else 'No')


S = input()
f = sum((int(x) for x in S))
print('Yes' if int(S) % f == 0 else 'No')


n = input()
print('YNeos'[int(n) % sum(map(int, n)) > 0::2])


n = input()
f = sum(map(int, n))
print('Yes' if int(n) % f == 0 else 'No')


s = input()
a = sum(list((int(c) for c in s)))
print('Yes' if int(s) % a < 1 else 'No')


S = input()
fn = sum(map(int, S))
print('Yes' if int(S) % fn == 0 else 'No')


import sys
Nstr = sys.stdin.readline().strip()
digit_s = 0
for n_i in Nstr:
	digit_s += int(n_i)
if int(Nstr) % digit_s == 0:
	print('Yes')
else:
	print('No')


N = int(input())

def keta_sum(N):
	if N < 10:
		return N
	else:
		return keta_sum(N // 10) + N % 10
if N % keta_sum(N) == 0:
	print('Yes')
else:
	print('No')


n = input()
l = list(map(int, str(n)))
print(('No', 'Yes')[int(n) % sum(l) == 0])


n = input()
print('Yes' if int(n) % sum((int(i) for i in list(n))) == 0 else 'No')


N = input()
X = sum(list(map(int, list(N))))
if int(N) % X == 0:
	print('Yes')
else:
	print('No')


n = str(input())
a = 0
for i in range(len(n)):
	a += int(n[i])
if int(n) % a == 0:
	print('Yes')
else:
	print('No')


n = int(input())
fx = sum(map(int, list(str(n))))
print(['No', 'Yes'][int(n % fx == 0)])


n = input()
s = 0
for i in range(len(n)):
	s += int(n[i])
print('Yes') if int(n) % s == 0 else print('No')


n = input()
l = [int(_) for _ in n]
print('No' if int(n) % sum(l) else 'Yes')


n = input()
print('No' if int(n) % sum(map(int, n)) else 'Yes')


a = input()
y = []
for i in range(len(a)):
	y.append(int(a[i]))
if int(a) % sum(y) == 0:
	print('Yes')
else:
	print('No')


n = input()
print('YNeos'[int(n) % sum([int(i) for i in n]) != 0::2])


x = input()
fx = sum(map(int, x))
print('Yes' if int(x) % fx == 0 else 'No')


n = int(input())
print('Yes' if n % sum([int(m) for m in str(n)]) == 0 else 'No')


n = input()
fx = sum(map(int, n))
print('Yes' if int(n) % fx == 0 else 'No')


a = input()
print('YNeos'[int(a) % sum([int(i) for i in a]) != 0::2])


n = int(input())
a = sum((int(i) for i in list(str(n))))
print('YNeos'[n % a != 0::2])


num = input()
print('Yes' if int(num) % sum(map(int, num)) == 0 else 'No')


X = input()
s = sum(map(int, X))
print('No' if int(X) % s else 'Yes')


n = str(input())
print(['No', 'Yes'][int(n) % sum([int(i) for i in list(n)]) == 0])


import math
a = input()
b = int(a)
print('Yes' if b % sum(map(int, a)) == 0 else 'No')


n = input()
a = sum(map(int, n))
print('Yes' if int(n) % a == 0 else 'No')


N = input()
t = sum(map(int, N))
print('No' if int(N) % t else 'Yes')


N = input()
x = 0
for i in range(len(N)):
	x += int(N[i])
if int(N) % x == 0:
	print('Yes')
else:
	print('No')


s = input()
print('YNeos'[int(s) % eval('+'.join(s)) > 0::2])


n = input()
a = sum(list(map(int, list(n))))
print('No') if int(n) % a else print('Yes')


n = input()
print(['No', 'Yes'][int(n) % sum([int(i) for i in n]) == 0])


def digitSum(k):
	if k == 0:
		return 0
	else:
		return digitSum(k // 10) + k % 10
N = int(input())
if N % digitSum(N) == 0:
	print('Yes')
else:
	print('No')


n = input()
m = sum(map(int, n))
if int(n) % m == 0:
	print('Yes')
else:
	print('No')


s = input()
print('YNeos'[int(s) % sum(map(int, s)) > 0::2])


n = input()
print(('No', 'Yes')[int(n) % sum(map(int, list(n))) == 0])


def main():
	N = int(input())
	X = N
	sum = 0
	while True:
		amari = N % 10
		sum += amari
		N //= 10
		if N == 0:
			break
	if X % sum == 0:
		return 'Yes'
	else:
		return 'No'
print(main())


N = input()
fN = sum([int(n) for n in N])
print('Yes' if int(N) % fN == 0 else 'No')


n = input()
x = sum(map(int, n))
print('Yes' if int(n) % x == 0 else 'No')


n = int(input())
print('No' if n % sum(map(int, list(str(n)))) else 'Yes')


n = int(input())
s = sum([int(c) for c in str(n)])
print('Yes' if n % s == 0 else 'No')


def main():
	N = int(input())
	s = list(str(N))
	H = 0
	for i in range(len(s)):
		H += int(s[i])
	if N % H == 0:
		print('Yes')
	else:
		print('No')
main()


def main():
	n = int(input())
	x = sum(map(int, str(n)))
	print('Yes' if n % x == 0 else 'No')
main()


n = input()
print(['No', 'Yes'][int(n) % sum([int(i) for i in n]) < 1])


N = input()
print(['No', 'Yes'][int(N) % sum([int(i) for i in N]) == 0])


N = input()
f = [int(_) for _ in N]
x = sum(f)
print('No' if int(N) % x else 'Yes')


n = input()
x = int(n)
fx = sum(map(int, list(n)))
print('YNeos'[x / fx % 1 != 0::2])


print('No' if (lambda x: int(x) % sum(list(map(int, list(x)))))(input()) else 'Yes')


A = input()
nu = int(A)
tmp = sum(map(int, list(A)))
print('Yes') if nu % tmp == 0 else print('No')


p = input()
print('YNeos'[int(p) % sum(map(int, p)) > 0::2])


s = input()
print('Yes' if int(s) % sum(map(int, list(s))) == 0 else 'No')


n = int(input())

def digitSum(n):
	s = str(n)
	array = list(map(int, s))
	return sum(array)
print('Yes' if n % digitSum(n) == 0 else 'No')


N = int(input())
s = sum(map(int, str(N)))
print(['No', 'Yes'][N % s == 0])


def harshad(n):
	if n % sum(map(int, list(str(n)))) == 0:
		return True
	else:
		return False
N = int(input())
print('Yes' if harshad(N) else 'No')


n = int(input())
f = 0
m = n
while m > 0:
	f += m % 10
	m //= 10
print(['No', 'Yes'][n % f == 0])


n = int(input())
n_init = n
m = 0
while n > 0:
	m += n % 10
	n //= 10
print('Yes' if n_init % m == 0 else 'No')


N = input()
print(['Yes', 'No'][int(N) % sum(map(int, N)) != 0])


n = input()
s = sum(map(int, n))
print('Yes' if int(n) % s == 0 else 'No')


n = int(input())
f = False
x = sum(list(map(int, str(n))))
if n % x == 0:
	f = True
if f:
	print('Yes')
else:
	print('No')


n = input()
print('Yes' if int(n) % eval('+'.join(list(n))) == 0 else 'No')


def findSumOfDigits(n):
	sum = 0
	while n > 0:
		sum += n % 10
		n //= 10
	return sum
ans = 0
n = int(input())
total = findSumOfDigits(n)
if n % total == 0:
	print('Yes')
else:
	print('No')


N = input()
print('YNeos'[int(N) % sum(map(int, N)) > 0::2])


N = input()
f = sum(map(int, N))
print('Yes' if int(N) % f == 0 else 'No')


n = int(input())
f = sum(map(int, str(n)))
print('No' if n % f else 'Yes')


n = int(input())
N = n
sum = int(0)
while n != 0:
	sum += n % 10
	n //= 10
if N % sum == 0:
	print('Yes')
else:
	print('No')


def digitsum(n):
	return sum(list(map(int, list(str(n)))))
N = int(input())
if N % digitsum(N) == 0:
	print('Yes')
else:
	print('No')


n = int(input())
print('YNeos'[n % sum(list(map(int, str(n)))) != 0::2])


N = input()
print('Yes' if not int(N) % sum([int(x) for x in N]) else 'No')


def is_harshad_number(x: int) -> bool:
	dividend = x
	sum_of_digits = 0
	for _ in range(len(str(x))):
		(x, mod) = divmod(x, 10)
		sum_of_digits += mod
	return dividend % sum_of_digits == 0

def answer(x: int) -> str:
	return 'Yes' if is_harshad_number(x) else 'No'

def main():
	x = int(input())
	print(answer(x))

def __starting_point():
	main()
__starting_point()


num = input()
table = list(num)
total = 0
for i in range(len(table)):
	total += int(table[i])
if int(num) % total == 0:
	print('Yes')
else:
	print('No')


import math
n = input()
print('Yes' if int(n) % sum(map(int, n)) == 0 else 'No')


a = input()
b = int(a)
s = 0
for i in range(len(a)):
	s = s + int(a[i])
if b % s == 0:
	print('Yes')
else:
	print('No')


import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):

	def assertIO(self, input, output):
		(stdout, stdin) = (sys.stdout, sys.stdin)
		(sys.stdout, sys.stdin) = (StringIO(), StringIO(input))
		resolve()
		sys.stdout.seek(0)
		out = sys.stdout.read()[:-1]
		(sys.stdout, sys.stdin) = (stdout, stdin)
		self.assertEqual(out, output)

	def test_入力例_1(self):
		input = '12'
		output = 'Yes'
		self.assertIO(input, output)

	def test_入力例_2(self):
		input = '57'
		output = 'No'
		self.assertIO(input, output)

	def test_入力例_3(self):
		input = '148'
		output = 'No'
		self.assertIO(input, output)

def resolve():
	N = input()
	s = 0
	for i in range(len(N)):
		s += int(N[i])
	if int(N) % s == 0:
		print('Yes')
	else:
		print('No')

def __starting_point():
	resolve()
__starting_point()


N = input()
print('YNeos'[bool(int(N) % sum((int(n) for n in N)))::2])


N = input()
N_int = int(N)
N_len = len(N)
N_wa = 0
for i in range(N_len):
	N_wa += int(N[i])
if N_int % N_wa == 0:
	print('Yes')
else:
	print('No')


S = input()
print(['Yes', 'No'][not 0 == int(S) % sum((int(s) for s in S))])


n = input()
n1 = len(n)
su = 0
for i in range(n1):
	su += int(n[i])
if int(n) % su == 0:
	print('Yes')
else:
	print('No')


x = input()
print('YNeos'[int(x) % sum(map(int, x)) != 0::2])


N = int(input())
strN = str(N)
keta_wa = 0
for i in range(len(strN)):
	keta_wa += int(strN[i])
if N % keta_wa == 0:
	print('Yes')
else:
	print('No')


N = input().strip()
print('Yes' if int(N) % sum(map(int, N)) == 0 else 'No')


import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
fx = sum([int(i) for i in str(n)])
if n % fx == 0:
	print('Yes')
else:
	print('No')


x = input()
sm = sum(map(int, x))
print('Yes' if int(x) % sm == 0 else 'No')


N = int(input())
l = list(str(N))
fx = 0
for i in l:
	fx += int(i)
if N % fx == 0:
	print('Yes')
else:
	print('No')


x = input()
print('No' if int(x) % sum(map(int, x)) else 'Yes')


n = int(input())
s = str(n)
sum = 0
for i in range(len(s)):
	sum += ord(s[i]) - ord('0')
if n % sum == 0:
	print('Yes')
else:
	print('No')


X = input()
print(['No', 'Yes'][int(X) % sum((int(T) for T in X)) == 0])


N = int(input())
f = 0
str_N = str(N)
for i in str_N:
	f += int(i)
if N % f == 0:
	print('Yes')
else:
	print('No')


a = input()
print('YNeos'[int(a) % sum(map(int, a)) != 0::2])


n = int(input())
c = 0
for i in str(n):
	c += int(i)
if n % c == 0:
	print('Yes')
else:
	print('No')


n = input()
print('Yes' if int(n) % sum([int(x) for x in n]) == 0 else 'No')


n = list(map(str, input()))
fn = 0
for i in range(len(n)):
	fn += int(n[i])
print('Yes' if int(''.join(n)) % fn == 0 else 'No')


n = input()
c = 0
for i in n:
	c += int(i)
print('YNeos'[int(n) % c != 0::2])


n = int(input())
x = n
n = str(n)
f = 0
for i in range(len(n)):
	y = int(n[i])
	f += y
if x % f == 0:
	print('Yes')
else:
	print('No')


N = int(input())
print('Yes' * (N % sum(list(map(int, str(N)))) == 0) or 'No')


n = input()
print('YNeos'[int(n) % sum([int(x) for x in n]) != 0::2])


N = int(input())
x = str(N)
s = 0
for i in range(len(x)):
	s += int(x[i])
if N % s == 0:
	ans = 'Yes'
else:
	ans = 'No'
print(ans)


s = input()
ss = sum(map(int, s))
if int(s) % ss == 0:
	print('Yes')
else:
	print('No')


n = int(input())
(tmp, nx) = (0, n)
while nx:
	tmp += nx % 10
	nx //= 10
if n % tmp:
	print('No')
else:
	print('Yes')


b = input()
f = int(b)
c = []
N = 0
for i in range(len(b)):
	c.append(int(b[i]))
d = f // int(sum(c))
e = f / int(sum(c))
if d == e:
	print('Yes')
else:
	print('No')


N = input()

def f(x):
	result = 0
	for i in range(len(x)):
		result += int(x[i])
	return result
if int(N) % f(N) == 0:
	print('Yes')
else:
	print('No')


num = int(input())
num = str(num)
n = list(map(int, num))
S = 0
for i in range(len(n)):
	S += int(n[i])
num = int(num)
if num % S == 0:
	print('Yes')
else:
	print('No')


n = input()
L = [int(n) for n in list(str(n))]
print('YNeos'[int(n) % sum(L) != 0::2])


n = input()
fn = sum(map(int, n))
print('Yes' if int(n) % fn == 0 else 'No')


def digit_sum(num):
	total_num = 0
	while num > 0:
		total_num += num % 10
		num //= 10
	return total_num
N = int(input())
if N % digit_sum(N) == 0:
	print('Yes')
	return
print('No')


N = input()
print('No' if int(N) % sum(map(int, list(N))) else 'Yes')


N = input()
n = sum(map(int, N))
print('Yes' if int(N) % n == 0 else 'No')


N = int(input())
X = 0
for i in str(N):
	X += int(i)
if N % X == 0:
	print('Yes')
else:
	print('No')


S = input()
sm = sum(map(int, S))
print('Yes' if int(S) % sm == 0 else 'No')


N = input()
q = 0
for i in N:
	q += int(i)
print(['No', 'Yes'][int(N) % q == 0])


N = input()
fX = sum([int(i) for i in list(N)])
X = int(N)
if X % fX == 0:
	print('Yes')
else:
	print('No')


s = input()
l = [int(a) for a in s]
print(['No', 'Yes'][int(s) % sum(l) == 0])


n = input().strip()
print('Yes' if int(n) % sum(map(int, n)) == 0 else 'No')


s = input()
print(['No', 'Yes'][int(s) % sum([int(c) for c in s]) == 0])


n = input()
n_int = int(n)
n_sum = 0
for s in n:
	n_sum += int(s)
if n_int % n_sum == 0:
	print('Yes')
else:
	print('No')


n = int(input())
print('Yes' if not n % sum(map(int, str(n))) else 'No')


n = input()
s = 0
for i in n:
	s += int(i)
print(['No', 'Yes'][int(n) % s == 0])


N = input()
B = sum(map(int, N))
print('Yes' if int(N) % B == 0 else 'No')


ipp = input()
n = [int(x) for x in ipp]
harshad = 0
for i in range(0, len(n)):
	harshad += n[i]
if int(ipp) % harshad == 0:
	print('Yes')
elif int(ipp) % harshad != 0:
	print('No')


N = input()
f = lambda X: sum((int(x) for x in X))
print('Yes' if int(N) % f(N) == 0 else 'No')


s = input()
print('YNeos'[bool(int(s) % sum(map(int, s)))::2])


N = int(input())
S = str(N)
L = len(S)
total = 0
for i in range(L):
	total += int(S[i])
if N % total == 0:
	ans = 'Yes'
else:
	ans = 'No'
print(ans)


n = int(input())
nn = str(n)
ha_num = 0
for i in nn:
	ha_num += int(i)
if n % ha_num == 0:
	print('Yes')
else:
	print('No')


x = input()
fx = 0
intx = int(x)
for i in range(len(x)):
	fx += int(x[i])
if intx % fx == 0:
	print('Yes')
else:
	print('No')