ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป ๋ฌธ์ œ

 

4796๋ฒˆ: ์บ ํ•‘

์ž…๋ ฅ์€ ์—ฌ๋Ÿฌ ๊ฐœ์˜ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๋‹ค. ๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋Š” ํ•œ ์ค„๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๊ณ , L, P, V๋ฅผ ์ˆœ์„œ๋Œ€๋กœ ํฌํ•จํ•˜๊ณ  ์žˆ๋‹ค. ๋ชจ๋“  ์ž…๋ ฅ ์ •์ˆ˜๋Š” int๋ฒ”์œ„์ด๋‹ค. ๋งˆ์ง€๋ง‰ ์ค„์—๋Š” 0์ด 3๊ฐœ ์ฃผ์–ด์ง„๋‹ค.

www.acmicpc.net


โœ๐Ÿป ํ’€์ด

๐ŸŽจ Go

// https://www.acmicpc.net/problem/4796
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	for i := 1; ; i++ {
		var l, p, v int
		fmt.Fscanln(reader, &l, &p, &v)
		if l == 0 && p == 0 && v == 0 {
			break
		}

		fmt.Fprintf(writer, "Case %d: %d\n", i, (v/p)*l+int(math.Min(float64(v%p), float64(l))))
	}
}

๐ŸŽจ Python3

# https://www.acmicpc.net/problem/4796
import sys

if __name__ == "__main__":
    i = 1
    while True:
        l, p, v = list(map(int, sys.stdin.readline().split()))
        if l == 0 and p == 0 and v == 0:
            break
        print("Case {}: {}".format(i, (v//p)*l + min(v%p, l)))
        i += 1
728x90
๋Œ“๊ธ€