|
|||
p_orderLet a be a list that stores a permutation a = (a0, a1, a2, …, an – 1) of order n, and let p be a natural number. We say that the permutation is p-sorted if for any x > 0 index, it is true that ax > a[(x – 1) / p], where [(x – 1) / p] is used to denote the integer part of (x – 1) / p. For example, (1,3,2,5,4) is a 3-sorted order 5 permutation, because a1 = 3 > 1 = a0, a2 = 2 > 1 = a0, a3 = 5 > 1 = a0, a4 = 4 > 3 = a1. There exist altogether 12 different order 5 permutations that are 3-sorted. These are the following: (1,2,3,4,5), (1,2,3,5,4), (1,2,4,3,5), (1,2,4,5,3), (1,2,5,3,4), (1,2,5,4,3), (1,3,2,4,5), (1,3,2,5,4), (1,3,4,2,5), (1,3,5,2,4), (1,4,2,3,5), (1,4,3,2,5). Given n and p, calculate the number of p-sorted order n permutations modulo 666013. Input SpecificationThe input has 10 lines, each of which containing natural numbers n and p, separated by a space (1 < p < n ≤ 600 000). Each tuple represents a problem that needs to be solved. Output SpecificationThe output needs to contain 10 numbers in separate lines, giving the corresponding answers for the 10 input problems. Sample Input
Output for Sample Input
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |