Connected Permutations
Practice
4.5 (2 votes)
Algorithms
Approved
Combinatorics
Fast fourier transform
Hard
Generating Functions
Problem
92% Success 506 Attempts 50 Points 5s Time Limit 256MB Memory 1024 KB Max Code
We say that permutation p of size n is connected if there is no k, \(1\leqslant k < n\), such that \(p(1), p(2), \dots, p(k)\) is permutation of \(1,2,\dots, k.\)
You are given a positive integer n. Find out number of connected permutations of size \(1,2,\dots,n\). As this numbers can be large, print them modulo \(924844033.\)
Input Format:
Single line containing integer n.
Output Format:
Output n lines, numbers of connected permutations of size \(1, 2, \dots, n\).
Constraints:
\( 1 \leqslant n \leqslant 500,000.\)
50 points
\(n \leqslant 5,000.\)
Submissions
Please login to view your submissions
Similar Problems
Points:50
8 votes
Tags:
AlgorithmsBinomial CoefficientsEulerian numberFast Fourier transformGenerating FunctionsHardStirling Numbers
Points:20
114 votes
Tags:
ApprovedEasyOpenPriority queueTrees
3.Sad Cuts
Points:50
4 votes
Tags:
AlgorithmsCombinatoricsFast Fourier transformHard
Editorial