πAlgorithm
[λ°±μ€ μκ³ λ¦¬μ¦] 25304λ²: μμμ¦ (Java, μλ° νμ΄)
Nsso
2023. 5. 11. 15:21
λ¬Έμ
https://www.acmicpc.net/problem/25304
25304λ²: μμμ¦
μ€μμ΄λ μ λ² μ£Όμ μ΄λ©΄μ μ²μμΌλ‘ μ½μ€νΈμ½λ₯Ό κ° λ΄€λ€. μ λ§ λ©μ‘λ€. κ·Έλ°λ°, λͺ κ° λ΄μ§λ μμλλ° μμνκ² λμ κΈμ‘μ΄ λμ€λ κ²μ΄λ€! μ€μμ΄λ μμμ¦μ 보면μ μ ννκ² κ³μ°λ κ²
www.acmicpc.net
λ¬Έμ μ€λͺ
λ¬Έμ νμ΄
Scannerλ₯Ό μ¬μ©νμ¬ κ΅¬ννμλ€.
μ½λ
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 a = 0;
int b = 0;
int sum = 0;
for (int i = 0; i < N; i++) {
a = sc.nextInt();
b = sc.nextInt();
sum += a * b;
}
if (sum == X) {
System.out.println("Yes");
} else {
System.out.println("No");
}
}
}