CF1566H.Xor-quiz

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This is an interactive problem.

You are given two integers cc and nn . The jury has a randomly generated set AA of distinct positive integers not greater than cc (it is generated from all such possible sets with equal probability). The size of AA is equal to nn .

Your task is to guess the set AA . In order to guess it, you can ask at most 0.65c\lceil 0.65 \cdot c \rceil queries.

In each query, you choose a single integer 1xc1 \le x \le c . As the answer to this query you will be given the bitwise xor sum of all yy , such that yAy \in A and gcd(x,y)=1gcd(x, y) = 1 (i.e. xx and yy are coprime). If there is no such yy this xor sum is equal to 00 .

You can ask all queries at the beginning and you will receive the answers to all your queries. After that, you won't have the possibility to ask queries.

You should find any set AA' , such that A=n|A'| = n and AA' and AA have the same answers for all cc possible queries.

输入格式

Firstly you are given two integers cc and nn ( 100c106100 \le c \le 10^6 , 0nc0 \le n \le c ).

输出格式

In the first line you should print an integer qq (0q0.65c)(0 \le q \le \lceil 0.65 \cdot c \rceil) — the number of queries you want to ask. After that in the same line print qq integers x1,x2,,xqx_1, x_2, \ldots, x_q (1xic)(1 \le x_i \le c) — the queries.

For these queries you should read qq integers, ii -th of them is the answer to the described query for x=xix = x_i .

After that you should print nn distinct integers A1,A2,,AnA'_1, A'_2, \ldots, A'_n — the set AA' you found.

If there are different sets AA' that have the same answers for all possible queries, print any of them.

If you will ask more than 0.65c\lceil 0.65 \cdot c \rceil queries or if the queries will be invalid, the interactor will terminate immediately and your program will receive verdict Wrong Answer.

After printing the queries and answers do not forget to output end of line and flush the output buffer. Otherwise, you will get the Idleness limit exceeded verdict. To do flush use:

  • fflush(stdout) or cout.flush() in C++;
  • System.out.flush() in Java;
  • flush(output) in Pascal;
  • stdout.flush() in Python;
  • Read documentation for other languages.

Hacks

You cannot make hacks in this problem.

输入输出样例

  • 输入#1

    10 6
    
    1 4 2 11 4 4 4

    输出#1

    7 10 2 3 5 7 1 6
    
    1 4 5 6 8 10

说明/提示

The sample is made only for you to understand the interaction protocol. Your solution will not be tested on the sample.

In the sample A={1,4,5,6,8,10}A = \{1, 4, 5, 6, 8, 10\} . 77 queries are made, 70.6510=77 \le \lceil 0.65 \cdot 10 \rceil = 7 , so the query limit is not exceeded.

Answers for the queries:

  • For 1010 : 11 is the only number in the set AA coprime with 1010 , so the answer is 11
  • For 22 : 110510=00121012=4101_{10} \oplus 5_{10} = 001_2 \oplus 101_2 = 4_{10} , where \oplus is the bitwise xor
  • For 33 : 1104105108101010=0001201002010121000210102=2101_{10} \oplus 4_{10} \oplus 5_{10} \oplus 8_{10} \oplus 10_{10} = 0001_2 \oplus 0100_2 \oplus 0101_2 \oplus 1000_2 \oplus 1010_2 = 2_{10}
  • For 55 : 110410610810=00012010020110210002=11101_{10} \oplus 4_{10} \oplus 6_{10} \oplus 8_{10} = 0001_2 \oplus 0100_2 \oplus 0110_2 \oplus 1000_2 = 11_{10}
  • For 77 : 1104105106108101010=000120100201012011021000210102=4101_{10} \oplus 4_{10} \oplus 5_{10} \oplus 6_{10} \oplus 8_{10} \oplus 10_{10} = 0001_2 \oplus 0100_2 \oplus 0101_2 \oplus 0110_2 \oplus 1000_2 \oplus 1010_2 = 4_{10}
  • For 11 : 1104105106108101010=000120100201012011021000210102=4101_{10} \oplus 4_{10} \oplus 5_{10} \oplus 6_{10} \oplus 8_{10} \oplus 10_{10} = 0001_2 \oplus 0100_2 \oplus 0101_2 \oplus 0110_2 \oplus 1000_2 \oplus 1010_2 = 4_{10}
  • For 66 : 110510=0001201012=4101_{10} \oplus 5_{10} = 0001_2 \oplus 0101_2 = 4_{10}
首页