Raj is a very smart kid who recently started learning computer programming. His coach gave him a cyclic array A having N numbers, and he has to perform Q operations on this array. In each operation the coach would provide him with a number X. After each operation, every element of the cyclic array would be replaced by the sum of itself and the element lying X positions behind it in the cyclic array. All these replacements take place simultaneously. For example, if the cyclic array was [a, b, c, d], then after the operation with X = 1, the new array would be [a+d, b+a, c+b, d+c]. He needs to output the sum of the elements of the final array modulus 10^9+7. He made a program for it but it’s not very efficient. You know he is a beginner, so he wants you to make an efficient program for this task because he doesn’t want to disappoint his coach.
What approach will be used to solve this question and what are cyclic array?
Hi @nitinchauhan0808_be04315530401452, LOGIC :
u dont need to calculate the sum by shifting again and again, anyway u will be adding the array sum of that array only even if u shift and add as u r adding all the elements so dont shift just keep updating the sum of array
see here for implementation https://ide.codingblocks.com/s/657171
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
The education is necessary because through this you become an expert and get acknowledge about different important aspects. DumpsTool products contain information that has been extracted from authentic and reliable sources. NSE5_FAZ-7.0 Practice Questions offer you updated knowledge about all the contents of the syllabus and will enable you to pass it with flying colors. If you need to go through the entire syllabus and learn each and every topic, choose our Study Guides that equip you with the best knowledge.