viewing paste Unknown #49004 | Java

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
import java.io.*;
import java.util.*;
import java.math.*;
 
public class Main
{
      static int maxn = 200005;
      static boolean isodd(long a, long b) {
          if((a&b)==b) return true;
          else return  false;
      }
 
    public static void main(String[] args)
    {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
 
            int t = in.nextInt();
            for(int i = 1; i <= t; i ++) {
                int a[] = new int [maxn];
                int b[] = new int [maxn];
                int n = in.nextInt();
                long m = in.nextLong();
                for(int j = 1; j <= n; j ++) {
                    a[j] = in.nextInt();
                }
                 for(int j = n; j >= 1; j --)
                    {
                        if(isodd(n + m - 1 - j, m - 1))
                        {
 
                            for(int k = n; k >= n - j + 1; k --)
                            {
                                b[k]^=a[k + j - n];
                            }
                        }
                    }
                 
                for(int k = 1; k <= n; k ++) {
                    if(k == 1) {
                        out.print(b[k]);
                    }
                    else out.print(" "+ b[k]);
                }
                out.println();
            
            }
            out.close();
        }   
    }
 
class InputReader
{
    BufferedReader buf;
    StringTokenizer tok;
    InputReader()
    {
        buf = new BufferedReader(new InputStreamReader(System.in));
    }
    boolean hasNext()
    {
        while(tok == null || !tok.hasMoreElements()) 
        {
            try
            {
                tok = new StringTokenizer(buf.readLine());
            } 
            catch(Exception e) 
            {
                return false;
            }
        }
        return true;
    }
    String next()
    {
        if(hasNext()) return tok.nextToken();
        return null;
    }
    int nextInt()
    {
        return Integer.parseInt(next());
    }
    long nextLong()
    {
        return Long.parseLong(next());
    }
    double nextDouble()
    {
        return Double.parseDouble(next());
    }
    BigInteger nextBigInteger()
    {
        return new BigInteger(next());
    }
    BigDecimal nextBigDecimal()
    {
        return new BigDecimal(next());
    }
}
Viewed 1103 times, submitted by ACGoxy.