백준 - 2057 팩토리얼 분해

AekT·2021년 11월 1일
post-thumbnail

백준 2057 팩토리얼 분해

문제 : https://www.acmicpc.net/problem/2057

Swift :

var input = Int(readLine()!)!
var res: Int = 2432902008176640000
var ans = "YES"
if !(input != 0){
    input = -1
}
for i in stride(from: 20, to: 0, by: -1){
    res /= i
    if input >= res{
        input -= res
    }
}
print((input != 0) ? "NO" : "YES")
profile
으악

0개의 댓글