Taene's
[백준] 브론즈V-Shares C++ 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
소스코드:
#include <iostream>
using namespace std;
int main() {
int n,s;
while(cin>>n>>s){
cout<<s/(n+1)<<"\n";
}
return 0;
}
다른 방법: C
#include <stdio.h>
int main(){
int n, s;
while (scanf("%d %d", &n, &s) != EOF){
printf("%d\n", s/(n+1));
}
return 0;
}
접근방법: n과 s의 입력이 끝나 EOF가 반환되기 전까지 s/(n+1)의 값을 출력한다.
'백준 > 브론즈' 카테고리의 다른 글
[백준] 브론즈3-수학-곱셈 C++ 2588번 (0) | 2023.08.23 |
---|---|
[백준] 브론즈V-킹, 퀸, 룩, 비숍, 나이트, 폰 C++ 3003번 (0) | 2023.08.23 |
[백준] 브론즈V-크냐? C++ 4101번 (0) | 2023.08.23 |
[백준] 브론즈V-아! C++ 4999번 (0) | 2023.08.23 |
[백준] 브론즈V-콜센터 C++ 5339번 (0) | 2023.08.23 |