ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
var n, cycle int
reader := bufio.NewReader(os.Stdin)
fmt.Fscanln(reader, &n)
var newN = n
for true {
cycle++
var sum int
if newN/10 == 0 {
sum = newN
} else {
sum = newN/10 + newN%10
}
newN = newN%10*10 + sum%10
if newN == n {
break
}
}
fmt.Println(cycle)
}
๐จ Python3
import sys
n = int(sys.stdin.readline())
cycle = 0
new_n = n
while True:
new_n = (new_n%10)*10 + (int(new_n/10) + new_n%10)%10
cycle = cycle + 1
if new_n == n:
break
print(cycle)
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 5543๋ฒ / ์๊ทผ๋ ๋ [Go] [Python3] (0) | 2020.04.04 |
---|---|
BOJ / 10039๋ฒ / ํ๊ท ์ ์ [Go] [Python3] (0) | 2020.04.03 |
BOJ / 10951๋ฒ / A+B - 4 [Go] [Python3] (0) | 2020.04.01 |
BOJ / 10952๋ฒ / A+B - 5 [Go] [Python3] (0) | 2020.03.31 |
BOJ / 10871๋ฒ / X๋ณด๋ค ์์ ์ [Go] [Python3] (0) | 2020.03.30 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ์๋ฐ
- go
- ๋ถํ ์ ๋ณต
- baekjoon
- ๋งฅ๋ถ
- dp
- BFS
- MongoDB
- python3
- ๋ธ๋ฃจํธํฌ์ค
- ์คํ
- AWS
- ์๊ฐ๊ต์ฒด
- java
- ๋งฅ๋ถํ๋ก
- ํ๋ก์ด๋์์ฌ
- ์ด๋ถํ์
- ๋ฐฑ์ค
- BOJ
- Golang
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ๋ชฝ๊ณ ๋๋น
- ํด์๋งต
- Algorithm
- ํ
- Macbook pro 2012 mid 13
- ์๊ณ ๋ฆฌ์ฆ
- ballet
- ๋ฐ๋
- dfs
- Total
- Today
- Yesterday