Задача 2. Rotate and Sum
Здравейте, някой има ли идея защо judge ми дава 87/100 и на тест 6 ми дава грешен отговор?
https://pastebin.com/Kd6XEPpa
2. Rotate and Sum
To “rotate an array on the right” means to move its last element first: {1, 2, 3} à {3, 1, 2}.
Write a program to read an array of n integers (space separated on a single line) and an integer k, rotate the array right k times and sum the obtained arrays after each rotation as shown below.
Examples
| Input | Output | Comments | 
| 3 2 4 -1 2 | 3 2 5 6 
 | rotated1[] = -1 3 2 4 rotated2[] = 4 -1 3 2 sum[] = 3 2 5 6 | 
| 1 2 3 1 | 3 1 2 
 | rotated1[] = 3 1 2 sum[] = 3 1 2 | 
| 1 2 3 4 5 3 | 12 10 8 6 9 
 | rotated1[] = 5 1 2 3 4 rotated2[] = 4 5 1 2 3 rotated3[] = 3 4 5 1 2 sum[] = 12 10 8 6 9 | 
Hints
- After r rotations the element at position i goes to position (i + r) % n.
- The sum[] array can be calculated by two nested loops: for r = 1 … k; for i = 0 … n-1.