CF1406E.Deleting Numbers
省选/NOI-
通过率:0%
时间限制:1.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an interactive problem.
There is an unknown integer x (1≤x≤n). You want to find x.
At first, you have a set of integers 1,2,…,n. You can perform the following operations no more than 10000 times:
- A a: find how many numbers are multiples of a in the current set.
- B a: find how many numbers are multiples of a in this set, and then delete all multiples of a, but x will never be deleted (even if it is a multiple of a). In this operation, a must be greater than 1.
- C a: it means that you know that x=a. This operation can be only performed once.
Remember that in the operation of type B a>1 must hold.
Write a program, that will find the value of x.
这是一个交互式问题。
存在一个未知整数 x(满足 1≤x≤n),你需要找出 x。
初始时,你拥有一个整数集合 {1,2,…,n}。你可以执行以下操作,至多 10000 次:
A a:查询当前集合中是 a 的倍数的元素个数;B a:查询当前集合中是 a 的倍数的元素个数,然后将这些倍数全部从集合中删除;但 x 永远不会被删除(即使它是 a 的倍数)。执行该操作时,要求 a>1;C a:表示你已确定 x=a。该操作只能执行一次。
注意:在类型 B 的操作中,必须满足 a>1。
请编写一个程序,找出 x 的值。
输入格式
The first line contains one integer n (1≤n≤105). The remaining parts of the input will be given throughout the interaction process.
第一行包含一个整数 n(1≤n≤105)。输入的其余部分将在交互过程中给出。
输入输出样例
输入#1
10 2 4 0
输出#1
B 4 A 2 A 8 C 4
说明/提示
Note that to make the sample more clear, we added extra empty lines. You shouldn't print any extra empty lines during the interaction process.
In the first test n=10 and x=4.
Initially the set is: 1,2,3,4,5,6,7,8,9,10.
In the first operation, you ask how many numbers are multiples of 4 and delete them. The answer is 2 because there are two numbers divisible by 4: 4,8. 8 will be deleted but 4 won't, because the number x will never be deleted. Now the set is 1,2,3,4,5,6,7,9,10.
In the second operation, you ask how many numbers are multiples of 2. The answer is 4 because there are four numbers divisible by 2: 2,4,6,10.
In the third operation, you ask how many numbers are multiples of 8. The answer is 0 because there isn't any number divisible by 8 in the current set.
In the fourth operation, you know that x=4, which is the right answer.
注意:为了使样例更清晰,我们额外添加了空行。在交互过程中,你不应输出任何额外的空行。
在第一个测试中,n=10 且 x=4。
初始集合为:1,2,3,4,5,6,7,8,9,10。
在第一次操作中,你询问集合中有多少个数是 4 的倍数,并将这些倍数删除。答案为 2,因为有两个数能被 4 整除:4,8。其中 8 将被删除,但 4 不会删除,因为数 x 永远不会被删除。此时集合变为 1,2,3,4,5,6,7,9,10。
在第二次操作中,你询问集合中有多少个数是 2 的倍数。答案为 4,因为有四个数能被 2 整除:2,4,6,10。
在第三次操作中,你询问集合中有多少个数是 8 的倍数。答案为 0,因为当前集合中没有任何数能被 8 整除。
在第四次操作中,你确定 x=4,即为正确答案。
输入解题思路,AI测评打分。不知道怎么写?