NPS-INR-Cyber-Programming-2021

The 2021 edition of the NPS Indiranagar interhouse Cyber Programming contest.

View on GitHub

Elon Musk’s Crazy Contraption

Problem Statement:

In the time that Elon Musk isn’t driving the price of obscure cryptocurrencies to the moon, he thinks of ideas for crazy contraptions. This week he built a machine which takes a number and does the following operations in order:

  1. Multiplies the number by 13
  2. Multiplies the number by 11
  3. Multiplies the number by 7
  4. Outputs all the distinct 3-digit numbers possible from the result of the above operations (such that each digit can only be used once).

Elon, to test his machine, does the following N times:

  1. Given a 3-digit positive number K, he feeds it to the contraption for processing.
  2. He then takes the numbers it gives as output, and sends it through the contraption again

Help Elon find the number of distinct 3-digit numbers which the device outputs over the N steps.

Constraints:

Subtask 1: 20 points

Subtask 2: 80 points

Input Format:

Output Format:

Sample input:

1 123 5 

Sample output:

27