In planting field, there are trees in a single row fromleft to right.each tree has avalue V.youcut trees fromleft to right and for each tree ofvalue Vthat you cut,youplant(V+1)% M trees on the right most end with values ranging from 0 to ((V+1)%M)-1.
Initially,there was only one tree with value 2.Find the total number of trees present after cutting K trees.
Example:
Input1:1
Input2:2
Output1:1
Comments
Leave a comment