Could u check why my my output is giving wrong ans:
i just observed the patters that after three operations the array retains the same confiquration.
import java.util.;
import java.io.;
import java.lang.*;
class cd207
{
public static void main(String args[])throws IOException
{
try
{
//takign input through IO
InputReader in = new InputReader(System.in);
OutputWriter out = new OutputWriter(System.out);
int t = in.readInt(),n,rep,rem;
long k;
while(t–>0)
{
n = in.readInt();
k = in.readLong();
int arr[] = IOUtils.readIntArray(in,n);
rem = (int)k%n;
rep = (int)k/n;
if(rep!=0)
{
op(arr,rem,rep%3);
}
else
{
for(int i=0;i<k;i++)
arr[i] = arr[i]^arr[arr.length-i-1];
}
for(int i=0;i<arr.length;i++)
{
out.print(arr[i]+" ");
out.flush();
}
out.printLine();
out.flush();
}
out.close();
}
catch(Exception e){
e.printStackTrace();
}
I can’t understand what this line is doing. For eg - If N=13 and K=45 which satisfies the case K>3N, then k = k%(3n) + 3n simply gives back the same value of k. Please explain.
Solution 2: We simply let K\gets K\bmod 3NK←Kmod3N and do what we’re told to do. When NN is odd, we need to deal with A[\frac{N-1}{2}]A[
2
N−1
] as a special case, though.