
반복문을 활용해서 문제풀이에 접근해보자
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int totalAmount = scan.nextInt();
int totalCount = scan.nextInt();
for (int i = 0; i < totalCount; i++) {
int amount = scan.nextInt() * scan.nextInt();
totalAmount -= amount;
}
if (totalAmount == 0) System.out.print("Yes");
else System.out.print("No");
}
}'1day 1coding > 백준 단계별 문제' 카테고리의 다른 글
| [백준/Java] 2438번: 별 찍기 - 1 (0) | 2023.01.15 |
|---|---|
| [백준/Java] 11022번: A+B - 8 (0) | 2023.01.15 |
| [백준/Java] 2480번: 주사위 세개 (0) | 2023.01.12 |
| [백준/Java] 2525번: 오븐 시계 (0) | 2023.01.11 |
| [백준/Java] 10430번: 나머지 (0) | 2023.01.11 |