코딩테스트

[백준] 25304 영수증

두두(DoDu) 2023. 12. 23. 19:25
반응형

- 🔍 URL

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;
        }
        System.out.println( (x == sum) ? "Yes":"No");
    }
}

 

 

  -💡 결과

반응형