MeetCode
Surjective Functions Small
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Run
Submit
Dark
Problem Statement
Solutions
Submissions
Surjective Functions Small
Hard
Computer Mathematics
Sets, Relations & Functions
29 views
Explanation
Complexity
Problem Statement
Count surjections from n to m for small n,m (
Input Format
Two integers n m.
Output Format
One integer.
Example
Input
3 2
Output
6
Constraints
n,m
Input / Output Format
Input Format
Two integers n m.
Output Format
One integer.
Constraints
n,m
Examples
Input:
3 2
Output:
6
Example Solution (Public)
Computer Mathematics
Use inclusion-exclusion: m^n - C(m,1)*(m-1)^n + C(m,2)*(m-2)^n ...
Official Solution Code
Wrap
Copy
Use inclusion-exclusion: m^n - C(m,1)*(m-1)^n + C(m,2)*(m-2)^n ...
Please
login
to submit solutions.
Editor
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Test Cases
Output
Submission Result
Input
3 2
Expected Output
6
Compile Output
Error
Output
Please
login
to submit solutions.