#25304 ์˜์ˆ˜์ฆ ๐Ÿ’ธ

sso0_zยท2022๋…„ 10์›” 25์ผ
0

๋ฐฑ์ค€

๋ชฉ๋ก ๋ณด๊ธฐ
4/40

๋ฌธ์ œ๐Ÿ“

์ฝ”๋“œ๐Ÿ’ป

x = int(input()) # ์˜์ˆ˜์ฆ ์ด ๊ธˆ์•ก
n = int(input()) # ์ด ๊ฐฏ์ˆ˜
sum = 0

for i in range(n):
  a,b = map(int,input().split())
  sum += a*b

if sum == x:
  print("Yes")
else:
  print("No")

๊ฒฐ๊ณผ๐Ÿ˜

ํ’€์ด๐Ÿ’ก

x : ์˜์ˆ˜์ฆ ์ด ๊ธˆ์•ก
n : ๊ตฌ๋งคํ•œ ๋ฌผ๊ฑด๋“ค์˜ ์ด ๊ฐฏ์ˆ˜

์ž…๋ ฅ๋ฐ›์€ n๊ฐœ๋งŒํผ a(๊ฐ ๋ฌผ๊ฑด์˜ ๊ฐ€๊ฒฉ), b(๊ฐ ๋ฌผ๊ฑด์˜ ๊ฐฏ์ˆ˜)๋ฅผ for๋ฌธ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.

if ์ด ํ•ฉ์ด ์˜์ˆ˜์ฆ ์ด ๊ธˆ์•ก๊ณผ ๊ฐ™๋‹ค๋ฉด, "Yes"
elif ๊ฐ™์ง€ ์•Š๋‹ค๋ฉด, "No"

profile
์ฑ„์†Œ

0๊ฐœ์˜ ๋Œ“๊ธ€