sm 기술 블로그
174. 25304(영수증) - 자바 본문
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 이다.
'문제 > 백준_자바' 카테고리의 다른 글
176. 1920(수 찾기) - 자바 (0) | 2022.08.14 |
---|---|
175. 25305(커트라인) - 자바 (0) | 2022.08.13 |
173. 3003(킹, 퀸, 룩, 비숍, 나이트, 폰) - 자바 (0) | 2022.08.13 |
172. 6549 (히스토그램에서 가장 큰 직사각형) - 자바 (0) | 2022.08.06 |
171. 10830(피보나치 수 6) - 자바 (0) | 2022.08.05 |
Comments