CF1566H.Xor-quiz
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an interactive problem.
You are given two integers c and n . The jury has a randomly generated set A of distinct positive integers not greater than c (it is generated from all such possible sets with equal probability). The size of A is equal to n .
Your task is to guess the set A . In order to guess it, you can ask at most ⌈0.65⋅c⌉ queries.
In each query, you choose a single integer 1≤x≤c . As the answer to this query you will be given the bitwise xor sum of all y , such that y∈A and gcd(x,y)=1 (i.e. x and y are coprime). If there is no such y this xor sum is equal to 0 .
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 A′ , such that ∣A′∣=n and A′ and A have the same answers for all c possible queries.
输入格式
Firstly you are given two integers c and n ( 100≤c≤106 , 0≤n≤c ).
输出格式
In the first line you should print an integer q (0≤q≤⌈0.65⋅c⌉) — the number of queries you want to ask. After that in the same line print q integers x1,x2,…,xq (1≤xi≤c) — the queries.
For these queries you should read q integers, i -th of them is the answer to the described query for x=xi .
After that you should print n distinct integers A1′,A2′,…,An′ — the set A′ you found.
If there are different sets A′ that have the same answers for all possible queries, print any of them.
If you will ask more than ⌈0.65⋅c⌉ 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} . 7 queries are made, 7≤⌈0.65⋅10⌉=7 , so the query limit is not exceeded.
Answers for the queries:
- For 10 : 1 is the only number in the set A coprime with 10 , so the answer is 1
- For 2 : 110⊕510=0012⊕1012=410 , where ⊕ is the bitwise xor
- For 3 : 110⊕410⊕510⊕810⊕1010=00012⊕01002⊕01012⊕10002⊕10102=210
- For 5 : 110⊕410⊕610⊕810=00012⊕01002⊕01102⊕10002=1110
- For 7 : 110⊕410⊕510⊕610⊕810⊕1010=00012⊕01002⊕01012⊕01102⊕10002⊕10102=410
- For 1 : 110⊕410⊕510⊕610⊕810⊕1010=00012⊕01002⊕01012⊕01102⊕10002⊕10102=410
- For 6 : 110⊕510=00012⊕01012=410