Please subscribe to the official Codeforces channel in Telegram via the link ×

How to do modulu operations and modulu inverse by non prime numbers?

Revision en3, by habib_rahman, 2017-02-24 09:39:35

Given N distinct integers from 1 to N, you have to find the number of ways the N integers can be rearranged in M empty slots such that, no integer matches with its slot index. Note that, slots are indexed from 1 to M.

Print the number of ways modulo 23377788.

0<=N<=M<100000 and It has 200 test cases.

I came up with a solution like this but not sure its correct or not. And have not any idea to modulu it by non prime.

Tags derangement, modulo, modular inverse


  Rev. Lang. By When Δ Comment
en3 English habib_rahman 2017-02-24 09:39:35 78
en2 English habib_rahman 2017-02-24 09:38:01 11 Tiny change: 'prime.\n![My solution ](http://' -> 'prime.\n![ ](http://' (published)
en1 English habib_rahman 2017-02-24 09:34:30 549 Initial revision (saved to drafts)