• + 0 comments

    Nice one!
    Here is my code in C.

    #include <stdio.h>
    #include <stdlib.h>
    
    
    int main(){
        int n,k,q;
        scanf("%d %d %d",&n,&k,&q);
        int a[100000],m,i = 0;
        
        while(i < n)
            scanf("%d",&a[(i++ + k) % n]); 
        
        while(q--){
            scanf("%d",&m);
            printf("%d\n",a[m]);
        }
        return 0;
    }
    

    Position resulting because of rotation is computed first using ((i++ + k) % n).Then the array elements are stored in these positions in the read ing stage itself using scanf() . Suggestions are welcome!