ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ 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
- ์๋ฐ
- BOJ
- ์ด๋ถํ์
- Macbook pro 2012 mid 13
- ๋ถํ ์ ๋ณต
- ๋ธ๋ฃจํธํฌ์ค
- ๋งฅ๋ถํ๋ก
- ๋ฐ๋
- ํด์๋งต
- baekjoon
- BFS
- ballet
- ๋งฅ๋ถ
- ์คํ
- dp
- dfs
- Golang
- MongoDB
- ์๊ณ ๋ฆฌ์ฆ
- ๋ฐฑ์ค
- Algorithm
- AWS
- ํ๋ก์ด๋์์ฌ
- ๋ชฝ๊ณ ๋๋น
- ํ
- go
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- java
- ์๊ฐ๊ต์ฒด
- python3
- Total
- Today
- Yesterday