새소식

알고리즘/문제풀이

백준 - 25304번 영수증

  • -

코드


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int total = Integer.parseInt(br.readLine());

        int n = Integer.parseInt(br.readLine());

        StringTokenizer st;
        
        int sum = 0;

        for (int i = 0; i < n; i++) {
            st = new StringTokenizer(br.readLine());

            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());
            
            sum += a*b;
        }

        System.out.println(sum == total ? "Yes" : "No");
    }
}

'알고리즘 > 문제풀이' 카테고리의 다른 글

백준 - 15552번 빠른 A+B  (0) 2023.07.14
백준 - 25314번 코딩은 체육과목 입니다  (0) 2023.07.14
백준 - 8393번 합  (0) 2023.07.14
백준 - 10950번 A+B - 3  (0) 2023.07.14
백준 - 2739번 구구단  (0) 2023.07.14
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.