https://www.acmicpc.net/problem/25304
25304번: 영수증
준원이는 저번 주에 살면서 처음으로 코스트코를 가 봤다. 정말 멋졌다. 그런데, 몇 개 담지도 않았는데 수상하게 높은 금액이 나오는 것이다! 준원이는 영수증을 보면서 정확하게 계산된 것
www.acmicpc.net
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 sum = 0;
for(int i = 0 ; i < N ; i++) {
int a = sc.nextInt();
int b = sc.nextInt();
sum += a*b;
}
if( X == sum) {
System.out.println("Yes");
}else {
System.out.println("No");
}
sc.close();
}
}
'프로그래밍언어 > 알고리즘' 카테고리의 다른 글
백준 15552번 빠른 A+B_JAVA (0) | 2023.05.04 |
---|---|
백준 25314 코딩은 체육과목 입니다_JAVA (0) | 2023.05.02 |
백준 8393 합_JAVA (0) | 2023.05.02 |
백준 10950 A+B - 3 _JAVA (0) | 2023.05.02 |
백준 2739번 구구단_JAVA (0) | 2023.05.02 |