0

Challenge question - > Changing Numbers

Combinatorics and number theory are very useful in computer science. Solve this problem to improve your skills in these fields. You are given integers and . Let's define . Initially, you have an integer . You can modify it in two ways: Multiply the current number by some number , where is a prime number and . If the current number is divisible by , divide it by , where is a prime number and . Then, we define as the number of distinct numbers you can get if you perform these modifications no more than times in total starting with . You need to find modulo . You are asked to find this sum to avoid printing a lot of numbers. Complete the function distinctNumbers which takes in two integers and and returns a single integer denoting the sum above. Input Format The single line contains two space-separated integers and . Constraints Additionally, for of the total points: . Output Format Print a single number denoting the answer. Sample Input 0 3 1 Sample Output 0 23 Explanation 0 Starting with , you can obtain the following numbers: , , . # Operation Result 0 - 1 1 1*2 2 1 1*3 3 Starting with , you can obtain the following numbers: , , , . # Operation Result 1 2/2 1 0 - 2 1 2*2 4 1 2*3 6 Starting with , you can obtain the following numbers: , , , . # Operation Result 1 3/3 1 0 - 3 1 3*2 6 1 3*3 9 So, , , and you should print . Sample Input 1 4 2 Sample Output 1 82 Default Code: #!/bin/python3 import os import sys # Complete the distinctNumbers function below. def distinctNumbers(n, k): # Return the number of distinct numbers you can get and return the answer modulo 1000000007 if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') nk = input().split() n = int(nk[0]) k = int(nk[1]) result = distinctNumbers(n, k) fptr.write(str(result) + '\n') fptr.close()

2nd May 2018, 4:46 PM
Anthony Perez
1 Odpowiedź
+ 1
Anthony Perez It seems your question appears to be an assignment. Please show us your attempt and use the 8 rules to get help from the community. https://www.sololearn.com/Blog/38/8-simple-rules-to-get-help-from-the-community *can be a code coach solution which is meant for you to do to help you establish your skills abilities and where you need to learn... not the community *one issued by a school or other institution *one issued or created by another platform *one that appears to be in the form of a challenge that was created by you or somewhere else. Your question will be reviewed by a team of moderators and will most likely be marked for deletion. https://www.sololearn.com/Discuss/1316935/?ref=app
6th Feb 2021, 10:34 PM
BroFar
BroFar - avatar