ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/2670
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var n int
fmt.Fscanln(reader, &n)
var realNumbers = make([]float64, n)
for i := 0; i < n; i++ {
fmt.Fscanln(reader, &realNumbers[i])
}
for i := 1; i < n; i++ {
mul := realNumbers[i-1] * realNumbers[i]
if realNumbers[i] < mul { // ์ด์ ์ ๊ฐ๊ณผ ํ์ฌ ๊ฐ์ ๊ณฑํ ๊ฐ์ด์ด ํ์ฌ ๊ฐ๋ณด๋ค ๋ ํฌ๋ฉด ๊ณฑํ ๊ฐ์ผ๋ก ๊ฐฑ์
realNumbers[i] = mul
}
}
var answer float64
for i := 0; i < n; i++ {
if answer < realNumbers[i] {
answer = realNumbers[i]
}
}
fmt.Fprintf(writer, "%.3f\n", answer)
}
๐จ Python3
# https://www.acmicpc.net/problem/2670
import sys
if __name__ == "__main__":
n = int(sys.stdin.readline())
real_numbers = []
for i in range(n):
real_numbers.append(float(sys.stdin.readline()))
for i in range(1, n):
mul = real_numbers[i-1] * real_numbers[i]
real_numbers[i] = max(mul, real_numbers[i])
answer = max(real_numbers)
print("{:.3f}".format(answer))
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 2910๋ฒ / ๋น๋ ์ ๋ ฌ [Go][Python3] (0) | 2021.02.14 |
---|---|
BOJ / 1822๋ฒ / ์ฐจ์งํฉ [Go][Python3] (0) | 2021.02.13 |
BOJ / 1543๋ฒ / ๋ฌธ์ ๊ฒ์ [Go][Python3] (0) | 2021.02.11 |
BOJ / 1485๋ฒ / ์ ์ฌ๊ฐํ [Go][Python3] (0) | 2021.02.10 |
BOJ / 2217๋ฒ / ๋กํ [Go][Python3] (0) | 2021.02.09 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- dp
- ๋ถํ ์ ๋ณต
- ์๊ฐ๊ต์ฒด
- ์๊ณ ๋ฆฌ์ฆ
- go
- ๋ฐ๋
- AWS
- java
- python3
- ๋งฅ๋ถ
- ํ๋ก์ด๋์์ฌ
- ์ด๋ถํ์
- ๋ฐฑ์ค
- dfs
- ๋งฅ๋ถํ๋ก
- ํ
- Algorithm
- MongoDB
- ํด์๋งต
- Golang
- ๋ชฝ๊ณ ๋๋น
- BFS
- BOJ
- ์๋ฐ
- ๋ธ๋ฃจํธํฌ์ค
- ballet
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ์คํ
- baekjoon
- Macbook pro 2012 mid 13
- Total
- Today
- Yesterday