[백준] 3733

당당·2023년 5월 26일
0

백준

목록 보기
126/179

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

📔문제

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

1 100
2 7
10 9
10 10

📺예제 출력 1

50
2
0
0

🔍출처

ICPC > Regionals > Europe > Southeastern European Regional Contest > SEERC 2010 J번


🧮알고리즘 분류

  • 수학
  • 사칙연산

📃소스 코드

import java.util.Scanner;

public class Code3733 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);

        while(sc.hasNext()){
            int N=sc.nextInt();
            N=N+1;//심사위원

            int S=sc.nextInt();

            System.out.println(S/N);
        }
    }
}


📰출력 결과


📂고찰

sc.hasNext()로 입력이 있는 동안만 반복하며,
심사위원도 함께 포함하여 나눈다 하였으므로 입력받은 N에 1을 더해줘야 한다.

profile
MySQL DBA 신입 지원

0개의 댓글