https://www.acmicpc.net/problem/25304
25304번: 영수증
준원이는 저번 주에 살면서 처음으로 코스트코를 가 봤다. 정말 멋졌다. 그런데, 몇 개 담지도 않았는데 수상하게 높은 금액이 나오는 것이다! 준원이는 영수증을 보면서 정확하게 계산된 것
www.acmicpc.net
단순구현 문제였습니다.
package backjun;
import java.util.Scanner;
public class Receipt {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int tot = in.nextInt();
int cnt = in.nextInt();
int sum = 0;
for(int i=0;i<cnt;i++){
int price = in.nextInt();
int count = in.nextInt();
sum += price*count;
}
if(tot-sum==0){
System.out.println("Yes");
}else{
System.out.println("No");
}
}
}
'IT_tech > 알고리즘' 카테고리의 다른 글
백준10757 ) 큰수 A+B - JAVA (0) | 2022.08.23 |
---|---|
백준2480 ) 주사위3개 JAVA (0) | 2022.08.21 |
백준)오븐시계 - 자바 (0) | 2022.08.19 |
백준) 1427 소트인사이드 -JAVA (0) | 2020.08.15 |
백준) 2751 수정렬하기 2 -JAVA (0) | 2020.08.05 |