https://www.acmicpc.net/problem/11050
package main
import (
"bufio"
"fmt"
"os"
)
func factorial(t int) int {
ans := 1
for i := t; i > 0; i-- {
ans *= i
}
return ans
}
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var n, k int
fmt.Fscanln(reader, &n, &k)
res := factorial(n) / (factorial(k) * factorial(n - k))
fmt.Fprintf(writer, "%d", res)
}
'Studies > Languages' 카테고리의 다른 글
Go: 테스트용 간단 REST API 앱 (0) | 2022.04.19 |
---|