The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 2 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
q1
Chef had a hard day and want to play little bit. The game is called "Chain". Chef has the sequence of symbols. Each symbol is either '-' or '+'. The sequence is called Chain if each two neighboring symbols of sequence are either '-+' or '+-'.
For example sequence '-+-+-+' is a Chain but sequence '-+-+--+' is not.
Help Chef to calculate the minimum number of symbols he need to replace (ex. '-' to '+' or '+' to '-') to receive a Chain sequence.
Input: 2 ---+-+-+++ ------- Output: 2 3
Example case 1.
We can change symbol 2 from '-' to '+' and symbol 9 from '+' to '-' and receive '-+-+-+-+-+'.
Example case 2.
We can change symbols 2, 4 and 6 from '-' to '+' and receive '-+-+-+-'.
q2
Devu likes to play with a lock of N dials. Each dial rotates from numbers 0 to 9 clockwise (i.e. 0 to 1, 2 to 3 and 8 to 9). You can not rotate from 9 to 0.
Initially all the dials of the lock are set to 0. From the current lock, Devu can move any dial to at most 10 different positions (i.e. 0 to 9), so there are total 10N different locks possible.
Let us say for a lock we define cost of converting the initial lock (all zeros) to this lock. For this, we have to rotate each dial to corresponding position in the lock. Cost of moving a single dial to value x takes x seconds.
eg. cost of moving to 123 is 1 + 2 + 3 = 6 and cost of moving to 99 is 9 + 9 is 18.
Now Devu has to hurry up to meet his girlfriend, So he has at most M seconds to spend, he wonders how many possible locks he can create such that when a lock is represented as a decimal number, it should be divisible by P. As answer could be large, print answer modulo 998244353.
Only line of input will contain three integers N, P, MM respectively. Use of MM is defined in the output section.
Print a single line containing MM + 1 integers, ith (0 based indexing) of them should represent the
answer for the problem with given N, P and M = i.
Input: 2 3 3 Output: 1 1 1 5 Input: 2 4 4 Output: 1 1 2 3 5
Example #1.
For M = 0, we can have only one lock, ie. all zeros 00, it is divisible by 3.
For M = 1, we can have only one lock, ie. all zeros 00, it is divisible by 3.
For M = 2, we can have only one lock, ie. all zeros 00, it is divisible by 3.
For M = 3, we can have 5 locks whose decimal representation is divisible by 3. They are 00, 03, 21, 30 and 12.
Example #2.
For M = 0, we can have only one lock, ie. all zeros 00, it is divisible by 4.
For M = 1, we can have only one lock, ie. all zeros 00, it is divisible by 4.
For M = 2, we can have 2 locks whose decimal representation is divisible by 4. They are 00 and 20.
For M = 3, we can have 3 locks whose decimal representation is divisible by 4. They are 00, 12 and 20.
For M = 4, we can have 5 locks whose decimal representation is divisible by 4. They are 00, 04, 12, 20 and 40.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll