Suppose you have n elements in the array 'a' numbered from 1 to n. It is...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Suppose you have n elements in the array 'a' numbered from 1 to n. It is possible to remove the i-th element of 'a' if the number a[i] and i are relatively co-prime i.e. gcd (a[i],i)=1. After an element is removed, the elements to the right are shifted to the left by one position. An array b with n integers such that 1sb[i]sn-i+1 is a removal sequence for the array a if it is possible to remove all elements of a, if you remove the b1-th element, then the b2-th,..., then the bn-th element. For example, let a-[42,314]: [19,19] is a removal sequence: when you remove the 1-st element of the array, the condition gcd(42,19)=1 holds, and the array becomes [314];when you remove the 1-st element again, the condition gcd(314,19)=1 holds, and the array becomes empty. [2,1] is not a removal sequence: when you try to remove the 2-nd element, the condition gcd(314,2)=1 is false. An array is special if it has at least two removal sequences. For example, the array [1,2,5] is special: it has removal sequences [3,1,1] and [1,2,1]. The array [42,314] is not special: the only removal sequence it has is [1,1]. You are given two integers n and m. You have to calculate the number of special arrays a such that the length of a is from 1 to n and each ai is an integer from 1 to m. Input Format The first line of the input contains two integers n and m. Constraints Print one integer - the number of special arrays a such that the length of a is from 1 to n and each a[i] is an integer from 1 to m. Since the answer can be very large, print it modulo 998244353. Output Format 2sn3-10^5 1sm10^12 Sample Input 0 10 24 Sample Output 0 406957500 Sample Input 1 24 Sample Output 1 8 Suppose you have n elements in the array 'a' numbered from 1 to n. It is possible to remove the i-th element of 'a' if the number a[i] and i are relatively co-prime i.e. gcd (a[i],i)=1. After an element is removed, the elements to the right are shifted to the left by one position. An array b with n integers such that 1sb[i]sn-i+1 is a removal sequence for the array a if it is possible to remove all elements of a, if you remove the b1-th element, then the b2-th,..., then the bn-th element. For example, let a-[42,314]: [19,19] is a removal sequence: when you remove the 1-st element of the array, the condition gcd(42,19)=1 holds, and the array becomes [314];when you remove the 1-st element again, the condition gcd(314,19)=1 holds, and the array becomes empty. [2,1] is not a removal sequence: when you try to remove the 2-nd element, the condition gcd(314,2)=1 is false. An array is special if it has at least two removal sequences. For example, the array [1,2,5] is special: it has removal sequences [3,1,1] and [1,2,1]. The array [42,314] is not special: the only removal sequence it has is [1,1]. You are given two integers n and m. You have to calculate the number of special arrays a such that the length of a is from 1 to n and each ai is an integer from 1 to m. Input Format The first line of the input contains two integers n and m. Constraints Print one integer - the number of special arrays a such that the length of a is from 1 to n and each a[i] is an integer from 1 to m. Since the answer can be very large, print it modulo 998244353. Output Format 2sn3-10^5 1sm10^12 Sample Input 0 10 24 Sample Output 0 406957500 Sample Input 1 24 Sample Output 1 8
Expert Answer:
Related Book For
Probability And Statistics
ISBN: 9780321500465
4th Edition
Authors: Morris H. DeGroot, Mark J. Schervish
Posted Date:
Students also viewed these economics questions
-
Explain how total pension liability differs from net pension liability.
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A...
-
Suppose that the weight of a typical American male follows a normal distribution with = 180 lb and = 30 lb. Also, suppose 91.92% of all American males weigh more than I weigh. a. What fraction of...
-
Why is the formal training of workers so important to most employers? Why dont employers simply let people learn about their jobs as they perform them?
-
If the market price of a share is less than its book value; is it a bargain? Why or why not?
-
Using the bid spot currency quotes shown in question 2 above, answer the following: a. What is the current cross spot rate of Mexican pesos/pounds sterling? b. What is the current cross spot rate of...
-
Shauna Miller is an accountant at Western Building Supplies. Recently, in the course of her normal processing of transactions and related documents, she noticed that two of her companys top sales...
-
Find the mean of the given probability distribution. The accompanying table shows the probability distribution for x, the number that shows up when a loaded die is rolled. Probability For a Loaded...
-
Donald is finally bowing to pressure from his friend Greta and has decided to retrofit his house to make it entirely reliant on renewable energy. The total cost of the equipment and works is 6,000....
-
What reasons might explain the (apparently) low usage rate of activitybased costing (ABC) systems in governmental organizations?
-
What is meant by the statement We are bound to a short-term focus?
-
Which capital investment appraisal techniques are most suitable for use in public sector organizations?
-
List and explain five rules of thumb for improving written communication.
-
Why is human error often an incomplete root cause?
-
You've determined that India presents the greatest potential for your solar kits. Now it's time to decide the best approach for launching your solar kits internationally. You recognize that there are...
-
You are the newly appointed tax practitioner to complete Emilys tax return and have downloaded the prefill report for Emilys tax return (hint, you can read what a prefill report is here (Links to an...
-
Given the probabilities of expected states of the economy shown here, and the expected returns to stocks A and B in those states, what is the standard deviation of a portfolio with weights of 40...
-
The controller of Getty Industries has collected the following monthly expense data for use in analysis the cost behavior of maintenance costs. Instructions (a) Determine the fixed and variable cost...
-
Stock W has an expected return of 12.4 percent and a beta of 1.8. If the expected market return is 10 percent, what is the risk-free rate? a. -5.6% b. 3.0% c. 5.6% d. 7.0%
Study smarter with the SolutionInn App