sm 기술 블로그

174. 25304(영수증) - 자바 본문

문제/백준_자바

174. 25304(영수증) - 자바

sm_hope 2022. 8. 13. 14:03
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int N = sc.nextInt();
		int sum = 0;

		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			sum += a * b;
		}
		
		if (sum == X) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

문제요약

영수증이 맞는지 확인하라

설명

매우 간단한 문제이다.

각 항목의 곱한 값에서 더한 값이 영수증 값과 같으면 Yes  아니면 NO 이다.

Comments