We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #172: Investigating numbers with few repeated digits

Project Euler #172: Investigating numbers with few repeated digits

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 172 from projecteuler.net

How many positive -digit numbers (without leading zeroes) are there such that no digit occurs more than times in ? Output the answer modulo .

Input Format

The first line of input contains two integers and . Here, is the number of queries. The following lines contain an integer each.

Constraints

Output Format

For each query, print the integer which is the answer to the problem modulo .

Sample Input 0

3 2
3
4

Sample Output 0

900
8991

Explanation 0

For the first query, each -digit number is valid. For the second query, each -digit number except for , , , , , , , , and is valid.

Author

adamant

Difficulty

Expert

Max Score

100

Submitted By

734

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy