AtCoder Beginner Contest 060 - Choose Integers

We ask you to select some number of positive integers, and calculate the sum of them.
It is allowed to select as many integers as you like, and as large integers as you wish.
You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.
Your objective is to make the sum congruent to C modulo B.
Determine whether this is possible.
If the objective is achievable, print YES. Otherwise, print NO.

-----Constraints-----
 - 1 ≤ A ≤ 100
 - 1 ≤ B ≤ 100
 - 0 ≤ C < B

-----Input-----
Input is given from Standard Input in the following format:
A B C

-----Output-----
Print YES or NO.

-----Sample Input-----
7 5 1

-----Sample Output-----
YES

For example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.

Difficulty: EASY

Starter code:

Solutions:
(A, B, C) = map(int, input().split())
for i in range(1, B + 1):
	if i * A % B == C:
		print('YES')
		break
else:
	print('NO')


(a, b, c) = map(int, input().split())
for k in range(1, 10001):
	if (k * a - c) % b == 0:
		print('YES')
		exit()
print('NO')


import math
(A, B, C) = map(int, input().split())
if C % math.gcd(A, B) == 0:
	print('YES')
else:
	print('NO')


(a, b, c) = map(int, input().split())
print('YES' if any((a * i % b == c for i in range(1, b + 1))) else 'NO')


(a, b, c) = map(int, input().split())
bool = False
for i in range(1, 101):
	if a * i % b == c:
		bool = True
if bool:
	print('YES')
else:
	print('NO')


(a, b, c) = map(int, input().split())
print(['NO', 'YES'][c in set((a * i % b for i in range(1, 10000)))])


(A, B, C) = map(int, open(0).readline().split())
import math
print('YES' if C % math.gcd(B, A % B) == 0 else 'NO')


(a, b, c) = map(int, input().split())
print('YNEOS'[all((a * i % b - c for i in range(99)))::2])


(a, b, c) = map(int, input().split())
ans = 'NO'
for i in range(1, 100):
	if a * i % b == c:
		ans = 'YES'
print(ans)


(a, b, c) = map(int, input().split())
ok = 'NO'
for i in range(1, b + 1):
	if i * a % b == c:
		ok = 'YES'
		break
print(ok)


def g(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
(a, b, c) = map(int, input().split())
print(['NO', 'YES'][c % g(a, b) == 0])


from fractions import gcd
(A, B, C) = map(int, input().split())
print('YES' if C % gcd(A, B) == 0 else 'NO')


(a, b, c) = map(int, input().split())
for i in range(1, 10 ** 6):
	if a * i % b == c:
		print('YES')
		exit()
print('NO')


(a, b, c) = map(int, input().split())
for i in range(a):
	if (b * i + c) % a == 0:
		print('YES')
		exit()
print('NO')


(A, B, C) = map(int, input().split())
if any([A * i % B == C for i in range(B)]):
	print('YES')
else:
	print('NO')


(A, B, C) = map(int, input().split())
A %= B
for i in range(1, B + 1):
	if A * i % B == C:
		print('YES')
		return
print('NO')


import fractions
(a, b, c) = map(int, input().split())
print('NO' if c % fractions.gcd(a, b) else 'YES')


(a, b, c) = map(int, input().split())
ans = 'NO'
for i in range(200):
	if (a * i - c) % b == 0:
		ans = 'YES'
print(ans)


(a, b, c) = map(int, input().split())
x = []
for i in range(b):
	x.append(a * -~i % b)
print('YNEOS'[c not in x::2])


(a, b, c) = map(int, input().split())
ans = 'NO'
for i in range(101):
	if a * i % b == c:
		ans = 'YES'
		print(ans)
		exit()
print(ans)


(a, b, c) = map(int, input().split())
flag = False
for i in range(b):
	if a * i % b == c:
		flag = True
print(['NO', 'YES'][flag])


(a, b, c) = map(int, input().split())
ans = 'NO'
for num in range(1, b + 1):
	if num * a % b == c:
		ans = 'YES'
		break
	else:
		pass
print(ans)


(A, B, C) = map(int, input().split())
a = 'NO'
for n in range(10000):
	if n % A == 0 and n % B == C:
		a = 'YES'
print(a)


(a, b, c) = map(int, input().split())
for i in range(1, b + 1):
	if a * i % b == c:
		print('YES')
		return
print('NO')


(a, b, c) = map(int, input().split())
A = []
for i in range(b):
	A.append(a * i % b)
print('YES' if c in A else 'NO')


(A, B, C) = map(int, input().split())
for n in range(1, 100):
	if A * n % B == C:
		print('YES')
		exit()
print('NO')


(a, b, c) = map(int, input().split())
for s in range(1, 100):
	if a * s % b == c:
		print('YES')
		exit()
print('NO')


(A, B, C) = map(int, input().split())
ans = 'NO'
for k in range(1000):
	if A * k % B == C:
		ans = 'YES'
print(ans)


import fractions
(n, m, a) = map(int, input().split())
if a % fractions.gcd(n, m) == 0:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout

def solve():
	(a, b, c) = list(map(int, input().split()))
	possible = False
	for k in range(b):
		if (a * k - c) % b == 0:
			possible = True
			break
	if possible:
		print('YES')
	else:
		print('NO')

def main():
	solve()

def __starting_point():
	main()
__starting_point()


def zz():
	return list(map(int, input().split()))
(a, b, c) = zz()
ans = 0
for i in range(1, b + 1):
	if a * i % b == c:
		ans = 1
		break
if ans == 0:
	print('NO')
else:
	print('YES')


import sys, math
from itertools import combinations as c, product as p
from collections import deque
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def si():
	return input()

def ii():
	return int(input())

def fi():
	return float(input())

def lstr():
	return input().split()

def lint():
	return list(map(int, input().split()))

def lintdec():
	return list(map(lambda x: int(x) - 1, input().split()))

def lnstr(n):
	return [input() for _ in range(n)]

def lnint(n):
	return [int(input()) for _ in range(n)]

def lint_list(n):
	return [lint() for _ in range(n)]
(A, B, C) = lint()
q = 0
while q <= 100:
	if (q * B + C) % A == 0:
		print('YES')
		break
	q += 1
else:
	print('NO')


(a, b, c) = input().split()
a = int(a)
b = int(b)
c = int(c)
d = 0
for i in range(1000):
	if a * i % b == c:
		d = d + 1
if d == 0:
	print('NO')
else:
	print('YES')


(a, b, c) = map(int, input().split())
l = max(a, b)
s = min(a, b)
while s != 0:
	(l, s) = (s, l % s)
print('NO' if c % l != 0 else 'YES')


(n, m, k) = map(int, input().split())
for i in range(1, 101):
	if n * i % m == k:
		print('YES')
		quit()
print('NO')


(A, B, C) = list(map(int, input().split()))
if A > B:
	(A, B) = (B, A)
while A:
	(A, B) = (B % A, A)
print('YES' if C % B == 0 else 'NO')


import math
(a, b, c) = map(int, input().split())
d = math.gcd(a, b)
print('YES' if c % d == 0 else 'NO')


from fractions import gcd
(a, b, c) = map(int, input().split())
g = gcd(a, b)
print('YES' if c % g == 0 else 'NO')


(a, b, c) = map(int, input().split())
for n in range(1, b + 1):
	if a * n % b == c:
		print('YES')
		exit()
print('NO')


(a, b, c) = map(int, input().split())
from fractions import gcd
print('YNEOS'[c % gcd(a, b) > 0::2])


import copy
(a, b, c) = map(int, input().split())
x = copy.deepcopy(a)
visited = [False] * (b + 1)
flg = True
while True:
	x %= b
	if x == c:
		break
	elif visited[x]:
		flg = False
		break
	else:
		visited[x] = True
		x += a
print('YES') if flg else print('NO')


(a, b, c) = map(int, input().split())
for i in range(b):
	if a * i % b == c:
		print('YES')
		break
	elif a * i % b == 0 and i > 0:
		print('NO')
		break


from fractions import *
(A, B, C) = map(int, input().split())
print('YNEOS'[C % gcd(A, B) > 0::2])


(a, b, c) = map(int, input().split())
for i in range(100):
	if (b * i + c) % a == 0:
		print('YES')
		return
print('NO')


(a, b, c) = map(int, input().split())
res = 0
for i in range(1, 101):
	if a * i % b == c:
		res += 1
print('YES') if res > 0 else print('NO')


(A, B, C) = map(int, input().split())
for i in range(1, B + 1):
	if (i * A - C) % B == 0:
		print('YES')
		exit()
print('NO')


(a, b, c) = map(int, input().split())
res = 'NO'
for i in range(b):
	if a * i % b == c:
		res = 'YES'
		break
print(res)


(a, b, c) = list(map(int, input().split()))
an = 'NO'
for i in range(b):
	d = a * i
	if d % b == c:
		an = 'YES'
print(an)


def answer(a: int, b: int, c: int) -> str:
	for i in range(1, b + 1):
		if a * i % b == c:
			return 'YES'
	return 'NO'

def main():
	(a, b, c) = map(int, input().split())
	print(answer(a, b, c))

def __starting_point():
	main()
__starting_point()


(a, b, c) = map(int, input().split())
for i in range(b):
	if i * a % b == c:
		print('YES')
		quit()
print('NO')


(n, m, k) = map(int, input().split())
for i in range(1, 100):
	if n * i % m == k:
		print('YES')
		exit()
print('NO')


import sys
(A, B, C) = list(map(int, input().split()))
for i in range(100):
	if C == A * i % B:
		print('YES')
		return
print('NO')


(a, b, c) = map(int, input().split())
modb = [0] * 100
for i in range(1, 100000):
	n = a * i
	m = n % b
	if modb[m] != 0:
		break
	modb[m] = 1
print('YES' if modb[c] == 1 else 'NO')


(A, B, C) = list(map(int, input().split()))
R = C % B
found = False
for n in range(1, 101):
	if n * A % B == R:
		found = True
		break
if found:
	print('YES')
else:
	print('NO')


ans = 'NO'
(a, b, c) = map(int, input().split())
memo = []
for i in range(1, 10 ** 9):
	tmp = a * i % b
	if tmp == c:
		ans = 'YES'
		break
	if tmp in memo:
		break
	else:
		memo.append(tmp)
print(ans)


(A, B, C) = list(map(int, input().split()))
calc = 0
for i in range(1000):
	calc += A
	rem = calc % B
	if rem == C:
		print('YES')
		return
print('NO')


(A, B, C) = map(int, input().split())
mod = []
for i in range(max(B, C)):
	res = A * i % B
	if res == C:
		ans = 'YES'
		break
	if res in mod:
		ans = 'NO'
		break
	mod.append(res)
print(ans)


import fractions as f
(a, b, c) = map(int, input().split())
print('YES' if c % f.gcd(a, b) == 0 else 'NO')


(a, b, c) = map(int, input().split())
n = a
cnt = 1
while cnt <= b:
	if n % b == c:
		print('YES')
		return
	cnt += 1
	n += a
print('NO')


(A, B, C) = map(int, input().split())
r = [A * k % B for k in range(B)]
print(['NO', 'YES'][C in r])


(A, B, C) = map(int, input().split())
for i in range(100):
	if ((C + B * i) / A).is_integer():
		print('YES')
		return
print('NO')


(a, b, c) = map(int, input().split())
ans = 'NO'
for i in range(1, b + 1):
	mod = a * i % b
	if mod == 0:
		continue
	elif c % mod == 0:
		ans = 'YES'
		break
print(ans)


(a, b, c) = map(int, input().split())
print('YES' if any(map(lambda i: a * i % b == c, range(b))) else 'NO')


import re
import copy

def accept_input():
	(a, b, c) = list(map(int, input().split()))
	return (a, b, c)
(a, b, c) = accept_input()
aamari = a % b
amaridict = {}
curamari = a % b
for i in range(b):
	curamari = (curamari + aamari) % b
	amaridict[curamari] = 1
if c in amaridict:
	print('YES')
else:
	print('NO')


(A, B, C) = map(int, input().split())
check = False
for i in range(1, B + 1):
	if A * i % B == C:
		check = True
print('YES' if check else 'NO')


(A, B, C) = map(int, input().split())
ans = 'NO'
i = 1
while i <= B:
	if i * A % B == C:
		ans = 'YES'
	i += 1
print(ans)


(A, B, C) = map(int, open(0).read().split())
print('YES' if any((A * i % B == C for i in range(1, B + 1))) else 'NO')


(A, B, C) = map(int, input().split())
mod = set()
tmp = 0
D = A
while tmp not in mod:
	mod.add(tmp)
	tmp = D % B
	if tmp == C:
		print('YES')
		return
	D += A
print('NO')


(a, b, c) = list(map(int, input().split()))
count = 0
for i in range(b + 1):
	if i * a % b == c:
		print('YES')
		count += 1
		break
	else:
		pass
if count == 0:
	print('NO')
else:
	pass


(a, b, c) = map(int, input().split())
print('YNEOS'[all(((a * k - c) % b for k in range(b)))::2])


(a, b, c) = map(int, input().split())
A = []
for i in range(1, b + 1):
	mod = a * i % b
	if mod in A:
		break
	A.append(mod)
A.sort()
if len(A) >= 2:
	i = A[1]
else:
	i = 0
if i == 0 and c == 0:
	print('YES')
	return
elif i == 0 and c != 0:
	print('NO')
	return
if c % i == 0:
	print('YES')
else:
	print('NO')


(A, B, C) = map(int, input().split())
if len([A for A in range(A, 10000, A) if A % B == C]):
	print('YES')
else:
	print('NO')


(a, b, c) = map(int, input().split())
cnt = 0
for i in range(1, 10 ** 5):
	if a * i % b == c:
		print('YES')
		break
	else:
		cnt += 1
		if cnt == 10 ** 5 - 1:
			print('NO')
			break


(A, B, C) = map(int, input().split())
ans = 'NO'
for i in range(1, 1000):
	a = A * i
	if a % B == C:
		ans = 'YES'
		break
print(ans)


from math import gcd
numbers = list(map(lambda x: int(x), input().split()))
(a, b, c) = (numbers[0], numbers[1], numbers[2])
print('YES') if not c % gcd(a, b) else print('NO')


(A, B, C) = map(int, input().split())
ans = 'NO'
for i in range(A):
	if (B * i + C) % A == 0:
		ans = 'YES'
print(ans)


(A, B, C) = list(map(int, input().split()))
s = 0
for i in range(1, B + 1):
	x = A * i % B
	if x == C:
		s = s + 1
	else:
		s = s
if s != 0:
	print('YES')
else:
	print('NO')


(a, b, c) = (int(x) for x in input().split())
print('YES' if c in [a * (x + 1) % b for x in range(b)] else 'NO')


import sys
(a, b, c) = map(int, input().split())
i = 1
l = []
while True:
	aa = a * i % b
	if aa in l:
		break
	l.append(aa)
	i += 1
	if aa != 0 and c % aa == 0:
		print('YES')
		return
print('NO')


(a, b, c) = map(int, input().split())
for x in range(10000):
	if a * x % b == c:
		print('YES')
		exit()
print('NO')


(A, B, C) = map(int, input().split())
print(['NO', 'YES'][any([A * i % B == C for i in range(1, B + 1)])])


(a, b, c) = map(int, input().split())
n = a
ans = 'NO'
for i in range(1, b + 1):
	if n % b == c:
		ans = 'YES'
		break
	else:
		n += a
print(ans)


lst = input().split()
A = int(lst[0])
B = int(lst[1])
C = int(lst[2])
L = []
for i in range(1, B + 1):
	L.append(A * i % B)
if C in L:
	print('YES')
else:
	print('NO')


(a, b, c) = [int(x) for x in input().split()]
ans = 'NO'
for i in range(b):
	if a * i % b == c:
		ans = 'YES'
print(ans)


(a, b, c) = map(int, input().split())
d = a % b
s = set()
while d not in s:
	s.add(d)
	d = (d + a) % b
if c in s:
	print('YES')
else:
	print('NO')


(a, b, c) = list(map(int, input().split()))
aa = a
s = a % b
data = []
while True:
	aa += a
	data.append(aa % b)
	if aa % b == s:
		break
data.sort()
if a % b == 0:
	print('NO')
elif c % data[1] != 0:
	print('NO')
else:
	print('YES')


import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce
rr = lambda : sys.stdin.readline().rstrip()
rs = lambda : sys.stdin.readline().split()
ri = lambda : int(sys.stdin.readline())
rm = lambda : list(map(int, sys.stdin.readline().split()))
rl = lambda : list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10 ** 9 + 7
(a, b, c) = rm()
len_ = 1
s = set()
s.add(a)
i = a
while len_ == len(s):
	i += a
	i %= b
	len_ += 1
	s.add(i)
for i in list(s):
	if i == c:
		print('YES')
		return
else:
	print('NO')


(a, b, c) = map(int, input().split())
res = 'NO'
x = a - b
for i in range(100):
	if x * i % b == c:
		res = 'YES'
print(res)


(a, b, c) = list(map(int, input().split()))
ans = 'NO'
for i in range(0, b + 1):
	for j in range(0, a + 1):
		if a * i == b * j + c:
			ans = 'YES'
			break
print(ans)


(a, b, c) = map(int, input().split())
d = sorted(set([a * i % b for i in range(1, b + 1)]))
print('YES' if c in d else 'NO')


(a, b, c) = list(map(int, input().split()))
while a % b != 0:
	(a, b) = (b, a % b)
print('YES' if c % b == 0 else 'NO')


(A, B, C) = map(int, input().split())
result = 'NO'
num = 0
for i in range(1, B + 1):
	num = A * i % B
	if num == C:
		result = 'YES'
		break
print(result)


(a, b, c) = [int(x) for x in input().split()]

def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x
if c % gcd(a, b) == 0:
	print('YES')
else:
	print('NO')


(a, b, c) = [int(i) for i in input().split()]
if c in [a * i % b for i in range(b)]:
	print('YES')
else:
	print('NO')


(a, b, c) = map(int, input().split())
e = [(i * b + c) % a for i in range(a + 1)]
print('NO' if 0 not in set(e) else 'YES')


(A, B, C) = map(int, input().split())

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
if A == 1:
	print('YES')
elif C % gcd(A, B) == 0:
	print('YES')
else:
	print('NO')


(a, b, c) = map(int, input().split())
judge = False
for i in range(b):
	if a * i % b == c:
		judge = True
		break
if judge:
	print('YES')
else:
	print('NO')


def __starting_point():
	(a, b, c) = map(int, input().split())
	for i in range(1000000):
		m = a * i % b
		if m == c:
			print('YES')
			return
	print('NO')
__starting_point()


(A, B, C) = [int(s) for s in input().split()]
print('YNEOS'[C not in [A * (i + 1) % B for i in range(B)]::2])


(a, b, c) = list(map(int, input().split()))
ans = []
for i in range(1, b + 1):
	ans.append(a * i % b)
print('YES' if c in ans else 'NO')


(A, B, C) = map(int, input().split())
a = 'NO'
for i in range(A, B * A, A):
	if i % B == C:
		a = 'YES'
print(a)


(a, b, c) = map(int, input().split())
import math
abgcd = math.gcd(a, b)
ans = 'YES' if c % abgcd == 0 else 'NO'
print(ans)


(a, b, c) = map(int, input().split())
s = [a * i for i in range(1, b + 1) if a * i % b == c]
print('YES' if len(s) > 0 else 'NO')


(a, b, c) = map(int, input().split())
print('NYOE S'[c in [a * s % b for s in range(99)]::2])


import sys
import copy
import math
import itertools
import numpy as np
(A, B, C) = [int(c) for c in input().split()]
a = []
cnt = 0
while True:
	cnt += A
	a.append(cnt % B)
	if C == cnt % B:
		print('YES')
		return
	elif a.count(cnt % B) > 1:
		print('NO')
		return


(a, b, c) = map(int, input().split())
A = {k * a % b for k in range(b)}
print('YES' if c in A else 'NO')


import math
(a, b, c) = map(int, input().split())
print('YNEOS'[c % math.gcd(a, b) > 0::2])


(a, b, c) = map(int, input().split())
ganma = a % b
if ganma == 0:
	if ganma == c:
		print('YES')
	else:
		print('NO')
else:
	mod_list = []
	for i in range(b):
		mod = i * ganma % b
		mod_list.append(mod)
	zero_one_list = []
	for i in range(b):
		if mod_list[i] == c:
			zero_one_list.append(1)
		else:
			zero_one_list.append(0)
	sum_list = sum(zero_one_list)
	if sum_list >= 1:
		print('YES')
	else:
		print('NO')


(A, B, C) = map(int, input().split())
dp = [0] * 1000
ans = 'NO'
cur_A = A
while 1:
	if cur_A % B == C:
		ans = 'YES'
		break
	elif dp[cur_A % B] == 1:
		ans = 'NO'
		break
	dp[cur_A % B] = 1
	cur_A += A
print(ans)


import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10 ** 6)

def zz():
	return list(map(int, sys.stdin.readline().split()))

def z():
	return int(sys.stdin.readline())

def S():
	return sys.stdin.readline()[:-1]

def C(line):
	return [sys.stdin.readline() for _ in range(line)]
(A, B, C) = zz()
for i in range(1, B + 1):
	if A * i % B == C:
		print('YES')
		return
print('NO')


from fractions import gcd
(a, b, c) = map(int, input().split())
if c % gcd(a, b) == 0:
	print('YES')
	exit()
print('NO')


(a, b, c) = map(int, input().split())
i = 0
flag = True
while flag:
	num = b * i
	if (num + c) % a == 0:
		print('YES')
		flag = False
	elif i >= 10 ** 5:
		print('NO')
		break
	else:
		i += 1


(A, B, C) = map(int, input().split())
for k in range(B):
	if k * A % B == C:
		print('YES')
		exit()
print('NO')


(A, B, C) = map(int, input().split(' '))
mod = []
pivot = 1
step = 1
while True:
	pivot = step * A % B
	if step * A % B == C:
		print('YES')
		break
	elif pivot in mod:
		print('NO')
		break
	else:
		mod.append(pivot)
		step = step + 1


(a, b, c) = map(int, input().split())
ans = 'NO'
for i in range(b):
	num = i * a
	mod = num % b
	if mod == c:
		ans = 'YES'
		break
print(ans)


(a, b, c) = map(int, input().split())
hist = []
ans = 'NO'
for i in range(1, b + 1):
	mod = a * i % b
	if mod == c:
		ans = 'YES'
		break
	elif mod in hist:
		break
	hist.append(mod)
print(ans)