반응형

1. 문제 번호 25304번


 

2. 문제 풀이 

2.1 Recursion의 가장 단순한 예제

 

나의 문제풀이 방식 및 순서


3. 소스 인증

import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int totalCost = Integer.parseInt(br.readLine());
        int itemCnt   = Integer.parseInt(br.readLine());

        String [] item = new String[itemCnt];
        int calCost = 0;

        for(int i = 0; i<itemCnt; i++){
            item[i] = br.readLine();
            StringTokenizer st = new StringTokenizer(item[i]);
            calCost += (Integer.parseInt(st.nextToken()) * Integer.parseInt(st.nextToken()));
        }

        System.out.print( totalCost == calCost ? "Yes" : "No" );
        
    } 
}

4. 추가 개념

728x90
반응형

'알고리즘(BOJ) 문제풀이' 카테고리의 다른 글

[BOJ/백준] 반복문_15552번  (0) 2024.05.08
[BOJ/백준] 반복문_25314  (0) 2024.05.08
[BOJ/백준] 반복문_8393번  (0) 2024.05.08
[BOJ/백준] 반복문_10950  (0) 2024.05.08
[BOJ/백준] 반복문_2739번  (0) 2024.05.08

+ Recent posts