남극

백준 10833 사과 - Java 본문

algorithm

백준 10833 사과 - Java

펭1구 2020. 3. 2. 07:27

package Baekjoon;

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

public class Baekjoon10833 {
	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		int n = toInt(bf.readLine());
		int result = 0;
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(bf.readLine()," ");
			int a = toInt(st.nextToken());
			int b = toInt(st.nextToken());
			result += b % a;
		}
		bf.close();
		System.out.println(result);
	}
	
	public static int toInt(String s) {
		return Integer.parseInt(s);
	}
}

'algorithm' 카테고리의 다른 글

백준 11654 아스키코드 - Java  (0) 2020.03.02
백준 2440 별찍기 3 (Java)  (0) 2020.03.02
백준 10797 10부제 (Java)  (0) 2020.03.02
백준 2490 윷놀이 - Java  (0) 2020.03.02
백준 2475 검증 수 - Java  (0) 2020.03.02
Comments