본문 바로가기
BaekJoon/Bronze

[BOJ/JAVA] 백준 3733 : Shares (자바)

by HoonSikE 2023. 7. 8.
반응형
SMALL
문제 정보
  문제명   - Shares
  난이도   - 브론즈 V
문제 번호 - 3733번

문제 링크

https://www.acmicpc.net/problem/3733

 

3733번: Shares

A group of N persons and the ACM Chief Judge share equally a number of S shares (not necessary all of them). Let x be the number of shares aquired by each person (x must be an integer). The problem is to compute the maximum value of x. Write a program that

www.acmicpc.net


문제
A group of N persons and the ACM Chief Judge share equally a number of S shares (not necessary all of them). Let x be the number of shares aquired by each person (x must be an integer). The problem is to compute the maximum value of x.
Write a program that reads pairs of integer numbers from an input text file. Each pair contains the values of 1 ≤ N ≤ 10000 and 1 ≤ S ≤ 109 in that order. The input data are separated freely by white spaces, are correct, and terminate with an end of file. For each pair of numbers the program computes the maximum value of x and prints that value on the standard output from the beginning of a line, as shown in the example below.

예제 입력/출력
예제 입력 예제 출력
1 100
2 7
10 9
10 10
50
2
0
0

알고리즘 분류
● 수학
● 사칙연산

소스코드
package Lv1_Bronze;

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

/**
 * @author HanHoon
 * @category 수학, 사칙연산
 * https://www.acmicpc.net/problem/3733
 */
public class BOJ_B5_3733_Shares {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = null;
        StringBuilder str = new StringBuilder();

        while(true){
            String line = br.readLine();
            if(line == null || line.equals(""))
                break;

            st = new StringTokenizer(line);

            int N = Integer.parseInt(st.nextToken());
            int S = Integer.parseInt(st.nextToken());

            str.append(S/(N+1)).append("\n");
        }

        System.out.print(str);
        br.close();
    }
}

 


BaekJoon List
 

BaekJoon List

BOJ Start!! ● [BOJ] 백준 회원가입, 시작하는 법 ● [BOJ] 등급(티어) 및 Solved.AC 적용 ● [BOJ/JAVA] 백준 소스코드 제출 시 유의사항(자바) Bronze ● Bronze V  - ● Bronze IV  - ● Bronze III  -..

han-hoon.tistory.com


  

기회는 준비된 자에게 찾아온다.

 


 

반응형
LIST

댓글