25分,67案例错了,后面全超时,快读也用了,到底怎样才能过,救救孩子呜呜呜
  • 板块P9227 异或积
  • 楼主sjx321
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/4/29 17:21
  • 上次更新2023/10/23 17:14:51
查看原帖
25分,67案例错了,后面全超时,快读也用了,到底怎样才能过,救救孩子呜呜呜
600632
sjx321楼主2023/4/29 17:21

import java.io.*;
public class Main {
	static StreamTokenizer s=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	static PrintWriter out=new PrintWriter(System.out);
	static long b[]=new long[100010];
	public static void main(String[]args)throws IOException
	{
		
		int t=nextint();
		while(t--!=0)
		{
			
			int n=nextint();
			long k=nextlong();
			long res=0;
			for(int i=0;i<n;i++)
			{
				b[i]=nextlong();
				res^=b[i];
			}
			if(n%2==0)
			{
				if(k%2==0)
				{
					for(int i=0;i<n;i++)
					{
						out.print(b[i]+" ");
						out.flush();
					}
				}
				else {
					for(int i=0;i<n;i++)
					{
						out.print((res^b[i])+" ");
						out.flush();
					}
					
				}
			}
			else {
				for(int i=0;i<n;i++)
				{
					out.print((res^b[i])+" ");
					out.flush();
				}
			}
			out.println();
			out.flush();
		}
		
	}
	public static int nextint()throws IOException
	{
		s.nextToken();
		return(int)s.nval;
	}
	public static long nextlong()throws IOException
	{
		s.nextToken();
		return (long) s.nval;
	}
}

2023/4/29 17:21
加载中...