ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/14916
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)
numOfFive, numOfTwo := 0, 0
var isAvailable bool
for n >= 0 {
if n%5 == 0 {
numOfFive = n / 5
isAvailable = true
break
} else {
n -= 2
numOfTwo++
}
}
if isAvailable {
fmt.Fprintln(writer, numOfFive+numOfTwo)
} else {
fmt.Fprintln(writer, -1)
}
}
๐จ Python3
# https://www.acmicpc.net/problem/14916
import sys
if __name__ == "__main__":
n = int(sys.stdin.readline())
num_of_five, num_of_two = 0, 0
is_available = False
while n >= 0:
if n%5 == 0:
num_of_five = n // 5
is_available = True
break
else:
n -= 2
num_of_two += 1
if is_available:
print(num_of_five + num_of_two)
else:
print(-1)
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 2303๋ฒ / ์ซ์ ๊ฒ์ [Go][Python3] (0) | 2021.01.29 |
---|---|
BOJ / 2635๋ฒ / ์ ์ด์ด๊ฐ๊ธฐ [Go][Python3] (0) | 2021.01.28 |
BOJ / 2422๋ฒ / ํ์ค์ ์ด ์ดํ๋ฆฌ์์ ๊ฐ์ ์์ด์คํฌ๋ฆผ์ ์ฌ๋จน๋๋ฐ [Go][Python3] (0) | 2021.01.26 |
BOJ / 1145๋ฒ / ์ ์ด๋ ๋๋ถ๋ถ์ ๋ฐฐ์ [Go][Python3] (0) | 2021.01.25 |
BOJ / 1969๋ฒ / DNA [Go][Python3] (0) | 2021.01.24 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ballet
- baekjoon
- Golang
- ์คํ
- ๋งฅ๋ถ
- ์๊ณ ๋ฆฌ์ฆ
- java
- ์ด๋ถํ์
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ๋งฅ๋ถํ๋ก
- python3
- ํ๋ก์ด๋์์ฌ
- ์๋ฐ
- ์๊ฐ๊ต์ฒด
- ๋ชฝ๊ณ ๋๋น
- BFS
- dfs
- AWS
- ๋ถํ ์ ๋ณต
- BOJ
- ๋ฐฑ์ค
- ํ
- ๋ธ๋ฃจํธํฌ์ค
- dp
- Algorithm
- ๋ฐ๋
- ํด์๋งต
- go
- MongoDB
- Macbook pro 2012 mid 13
- Total
- Today
- Yesterday