NO.25304
풀이코드
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int n = sc.nextInt();
int total = 0;
for(int i=0; i<n; i++){
int a = sc.nextInt();
int b = sc.nextInt();
total += a*b;
}
sc.close();
if(x==total){
System.out.println("Yes");
}
else{
System.out.println("No");
}
}
}
📌 구매한 품목의 가격과 수량을 곱해서 더하는 total 값을 만들어 x와 비교시켰다.
'JAVA-BAEKJOON > 3단계 반복문' 카테고리의 다른 글
[백준/03-06] 15552 빠른 A+B (0) | 2024.02.26 |
---|---|
[백준/03-05] 25314 코딩은 체육과목 입니다 (0) | 2024.02.26 |
[백준/03-03] 8393 합 (0) | 2024.02.22 |
[백준/02-02] 10950 A+B - 3 (0) | 2024.02.22 |
[백준/03-01] 2739 구구단 (0) | 2024.02.22 |