Codechef Long Challenge – Array Modification – MARM

This video very clearly explains the problem statement , logic to solve the problem and also the correct solution.

What is the problem statement?

In this question, a sequence is provided to us and an integer K, we need to perform the given operations K number of time. Each operation will modify the sequence, we need to print the final sequence after K operations are performed.

How to solve the problem?

The approach for sub-task:1 is straightforward. We just need to perform the given operations K number of times and it will be accepted.

The problem is k value can be as big as 10^12, so it will not be accepted in 1 sec, as around 10^8 operations are allowed.

The approach of sub-task:2 is finding the pattern, in which the sequence is repeating after a certain number of times depending on the size of the sequence.

Once we find the pattern, the K value will be calculated and the same approach of sub-task:1 will be used. This K value will always be smaller than 10^8, so the code will work for the given time limit and constraints.

The pattern and the approach to find it is explained very well in the video.

Do not forget to share it with your coder friends.

Learn coding with experts: http://bit.ly/2VK13qf

Source

0

By admin

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x