ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/4573
package main
import (
"bufio"
"fmt"
"math"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var menu int
for {
menu++
var n int
fmt.Fscanln(reader, &n)
if n == 0 {
break
}
var selectedDiamater int
var lowPricePerSquare = math.MaxFloat64
for i := 0; i < n; i++ {
var diameter, price int
fmt.Fscanln(reader, &diameter, &price)
var radius = float64(diameter) / 2.0
var pricePerSquare = float64(price) / (radius * radius * math.Phi)
if pricePerSquare < lowPricePerSquare {
lowPricePerSquare = pricePerSquare
selectedDiamater = diameter
}
}
fmt.Fprintf(writer, "Menu %d: %d\n", menu, selectedDiamater)
}
}
๐จ Python3
# https://www.acmicpc.net/problem/4573
import sys
import math
if __name__ == "__main__":
menu = 0
while True:
menu += 1
n = int(sys.stdin.readline())
if n == 0:
break
selected_diamter = 0
low_price_per_square = 10000
for i in range(n):
diameter, price = list(map(int, sys.stdin.readline().split()))
radius = diameter/2.0
price_per_square = price / (radius*radius*math.pi)
if price_per_square < low_price_per_square:
low_price_per_square = price_per_square
selected_diamter = diameter
print("Menu {}: {}".format(menu, selected_diamter))
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 3182๋ฒ / ํ๋์ด๋ ๊ณต๋ถ๊ฐ ํ๊ธฐ ์ซ์ด! [Go][Python3] (0) | 2020.12.26 |
---|---|
BOJ / 10708๋ฒ / ํฌ๋ฆฌ์ค๋ง์ค ํํฐ [Go][Python3] (0) | 2020.12.25 |
BOJ / 1392๋ฒ / ๋ ธ๋ ์ ๋ณด [Go][Python3] (0) | 2020.12.19 |
BOJ / 2947๋ฒ / ๋๋ฌด ์กฐ๊ฐ [Go][Python3] (0) | 2020.12.18 |
BOJ / 2468๋ฒ / ์์ ์์ญ [Go][Python3] (0) | 2020.12.16 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- MongoDB
- ํด์๋งต
- ๋งฅ๋ถ
- ๋ชฝ๊ณ ๋๋น
- ํ
- Macbook pro 2012 mid 13
- ๋ถํ ์ ๋ณต
- ์คํ
- ๋ธ๋ฃจํธํฌ์ค
- ๋ฐ๋
- ๋งฅ๋ถํ๋ก
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- go
- ์๋ฐ
- ์๊ณ ๋ฆฌ์ฆ
- java
- dfs
- ์ด๋ถํ์
- Algorithm
- python3
- baekjoon
- BOJ
- ํ๋ก์ด๋์์ฌ
- ์๊ฐ๊ต์ฒด
- ballet
- AWS
- Golang
- BFS
- ๋ฐฑ์ค
- dp
- Total
- Today
- Yesterday