ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/1057
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var n, jimin, hansu int
fmt.Fscanln(reader, &n, &jimin, &hansu)
var round int
for round < n {
round++
if jimin%2 == 0 {
jimin /= 2
} else {
jimin = jimin/2 + 1
}
if hansu%2 == 0 {
hansu /= 2
} else {
hansu = hansu/2 + 1
}
if jimin == hansu {
fmt.Fprintln(writer, round)
return
}
}
fmt.Fprintln(writer, -1)
}
๐จ Python3
# https://www.acmicpc.net/problem/1057
import sys
if __name__ == "__main__":
n, jimin, hansu = list(map(int, sys.stdin.readline().split()))
round = 0
while round < n:
round += 1
if jimin%2 == 0:
jimin //= 2
else:
jimin = jimin//2 + 1
if hansu%2 == 0:
hansu //= 2
else:
hansu = hansu//2 + 1
if jimin == hansu:
print(round)
sys.exit()
print(-1)
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 10974๋ฒ / ๋ชจ๋ ์์ด [Go][Python3] (0) | 2021.03.29 |
---|---|
BOJ / 2960๋ฒ / ์๋ผํ ์คํ ๋ค์ค์ ์ฒด [Go][Python3] (1) | 2021.03.28 |
BOJ / 11048๋ฒ / ์ด๋ํ๊ธฐ [Go][Python3] (0) | 2021.03.26 |
BOJ / 1991๋ฒ / ํธ๋ฆฌ ์ํ [Go][Python3] (0) | 2021.03.25 |
BOJ / 11057๋ฒ / ์ค๋ฅด๋ง ์ [Go][Python3] (0) | 2021.03.24 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ์๊ฐ๊ต์ฒด
- dfs
- dp
- ๋ถํ ์ ๋ณต
- ์ด๋ถํ์
- ๋ธ๋ฃจํธํฌ์ค
- MongoDB
- ๋งฅ๋ถ
- ํด์๋งต
- ์๊ณ ๋ฆฌ์ฆ
- python3
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- go
- ์คํ
- ํ๋ก์ด๋์์ฌ
- ์๋ฐ
- ํ
- ๋ฐ๋
- ballet
- Algorithm
- Golang
- java
- BOJ
- ๋ฐฑ์ค
- baekjoon
- ๋งฅ๋ถํ๋ก
- AWS
- Macbook pro 2012 mid 13
- ๋ชฝ๊ณ ๋๋น
- BFS
- Total
- Today
- Yesterday