• + 1 comment

    What a powerful and flexible language Perl

    chomp(($n, $k, $q)=split(/ /,<>));
    chomp(my @A=split(/ /,<>));
    while(<>){ print $A[($_-$k)%$n],"\n"; }