Back to problems Sign in to unlock
Codeforces
Easy
Combinatorics
Math
Combination
Compute the number of ways to choose items from distinct items.
Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Problem Statement
Combination
Given two integers and , determine how many different groups of size can be formed from distinct items.
This is the standard combination count, often written as or .
You may assume the inputs are valid and fit in normal integer ranges for the intended solution approach.
Input Format
- Two integers and .
- They represent the total number of distinct items and the size of the group to choose.
Output Format
- Print a single integer: the number of ways to choose exactly items from distinct items.
Constraints
- is small enough that the result fits in the expected integer type for the problem setting.
Examples
Sample cases returned by the problem API.
Example 1
Input
5 2
Output
10
Explanation
There are ways to choose 2 items from 5 distinct items.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.
Guided hints
Editorial and discussion links
Concept map and variants
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.