Avatar
swift-5.2.5-RELEASE for ubuntu 16.04で再現しますね。-Ouncheckedを外すと起きない。 $ pbpaste func main() { let K = Int(readLine()!)! if !K.isMultiple(of: 9) { print(0) return } var dp: [Int] = Array(repeating: 0, count: K+1) dp[0] = 1 for i in 1...K { for j in max(0, i-9)..<i { dp[i] = (dp[i] + dp[j]) % (Int(1e9) + 7) //print(terminator: "") } } print(dp[K]) } main() $ pbpaste|docker run -i norionomura/swift:5.2 sh -c 'swiftc -Ounchecked -; echo 9|./main' 1 $ pbpaste|docker run -i norionomura/swift:5.2 sh -c 'swiftc -; echo 9|./main' 256 $ pbpaste|docker run -i norionomura/swift:5.3 sh -c 'swiftc -Ounchecked -; echo 9|./main' 256 $ pbpaste|docker run -i norionomura/swift:5.3 sh -c 'swiftc -; echo 9|./main' 256 (edited)
11:34 AM
swift-5.3.3-RELEASEでは起きない。