본문 바로가기
알고리즘 & 자료구조/백준

백준 1703

by 신재권 2021. 11. 17.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main1703 {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			StringTokenizer st = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(st.nextToken()); //나무의 나이 입력
			if(a == 0){
				break;
			}
			int result = 1;
			for(int i = 0; i< a ; i++){
				int n = Integer.parseInt(st.nextToken()); //splitting factor 수
				int g = Integer.parseInt(st.nextToken()); //가지치기 한 수
				//result = 생장점의 개수
                //생장점개수 * 늘어난 가지수 - g = 나뭇잎의개수(생장점의 개수)
				result = result * n - g; 
			}
			System.out.println(result);
		}

	}

}

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 2183  (0) 2021.11.19
백준2154  (0) 2021.11.18
백준 1333  (0) 2021.11.16
백준 1308  (0) 2021.11.15
백준 1296  (0) 2021.11.14