Partial Permutations(부분 순열)
https://rosalind.info/problems/pper/
ROSALIND | Partial Permutations
It appears that your browser has JavaScript disabled. Rosalind requires your browser to be JavaScript enabled. Partial Permutations solved by 4987 Partial Gene Orderings Similar species will share many of the same genes, possibly with modifications. Thus,
rosalind.info
Problem
A partial permutation is an ordering of only kk objects taken from a collection containing nn objects (i.e., k≤nk≤n). For example, one partial permutation of three of the first eight positive integers is given by (5,7,2)(5,7,2).
The statistic P(n,k)P(n,k) counts the total number of partial permutations of kk objects that can be formed from a collection of nn objects. Note that P(n,n)P(n,n) is just the number of permutations of nn objects, which we found to be equal to n!=n(n−1)(n−2)⋯(3)(2)n!=n(n−1)(n−2)⋯(3)(2) in “Enumerating Gene Orders”.
Given: Positive integers nn and kk such that 100≥n>0100≥n>0 and 10≥k>010≥k>0.
Return: The total number of partial permutations P(n,k)P(n,k), modulo 1,000,000.
Sample Dataset
21 7
Sample Output
51200
이 문제는 부분 순열을 구하는 문제이다. 부분 순열이다 n개 중에서 k개를 고른 이후 그 k개를 나열하는 가짓수이다. 즉 nCk * k!이다. 이 수식만을 구현하면 크게 어려울 것은 없다.
from Bio import SeqIO
def fact(n):
re=1
for i in range(1,n+1):
re*=i
return re
a,b = map(int,input().split())
print(fact(a)//fact(a-b)%1000000)#모듈러