Kotlin/Kotlin 알고리즘

백준 3733번 Shares Kotlin 구현해보기

kimc 2022. 10. 19. 21:56

```

백준 3733번 Shares Kotlin 구현해보기

```

Kimc Kotlin Study

이번 글을 통해 배워갈 내용

  1. 백준 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

 

백준 3733번 Shares는

난이도 브론즈 등급의 문제로서

사람 수 N과 주식의 수 S 가 주어지면

 

S 개의 주식을 최대한 많이 N+1의 사람들에게 균등하게 배분하려면

몇 개씩 나눠야 하는지 계산해주면 되는 문제입니다.


30분 정도 위에 링크를 방문하셔서 풀어보시고

안 풀리시는 경우에만 아래 해답을 봐주시면 감사하겠습니다.


입력을 받고

정해진 조건에 맞춰서 계산을 해서 출력해주면 되는

문제입니다.

 

import java.util.*

fun main(args: Array<String>) {
    val sb = StringBuilder()
    val sc = Scanner(System.`in`)
    var n: Int
    var s: Int
    while (sc.hasNext()) {
        n = sc.nextInt()
        s = sc.nextInt()
        sb.append(s / (n + 1)).append("\n")
    }
    if (sb.isNotEmpty()) {
        sb.setLength(sb.length - 1)
    }
    print(sb)
}

// https://codemasterkimc.tistory.com/

 

 

읽어주셔서 감사합니다

 

무엇인가 얻어가셨기를 바라며

 

오늘도 즐거운 코딩 하시길 바랍니다 ~ :)

 


 

728x90