CF1406E.Deleting Numbers

省选/NOI-

通过率:0%

时间限制:1.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

This is an interactive problem.

There is an unknown integer xx (1≤x≤n1\le x\le n). You want to find xx.

At first, you have a set of integers 1,2,…,n{1, 2, \ldots, n}. You can perform the following operations no more than 1000010000 times:

  • A aa: find how many numbers are multiples of aa in the current set.
  • B aa: find how many numbers are multiples of aa in this set, and then delete all multiples of aa, but xx will never be deleted (even if it is a multiple of aa). In this operation, aa must be greater than 11.
  • C aa: it means that you know that x=ax=a. This operation can be only performed once.

Remember that in the operation of type B a>1a \gt 1 must hold.

Write a program, that will find the value of xx.

这是一个交互式问题。

存在一个未知整数 xx(满足 1≤x≤n1\le x\le n),你需要找出 xx。

初始时,你拥有一个整数集合 {1,2,…,n}\{1, 2, \ldots, n\}。你可以执行以下操作,至多 1000010000 次:

  • A a:查询当前集合中是 aa 的倍数的元素个数;
  • B a:查询当前集合中是 aa 的倍数的元素个数,然后将这些倍数全部从集合中删除;但 xx 永远不会被删除(即使它是 aa 的倍数)。执行该操作时,要求 a>1a > 1;
  • C a:表示你已确定 x=ax = a。该操作只能执行一次。

注意:在类型 B 的操作中,必须满足 a>1a > 1。

请编写一个程序,找出 xx 的值。

输入格式

The first line contains one integer nn (1≤n≤1051\le n\le 10^5). The remaining parts of the input will be given throughout the interaction process.

第一行包含一个整数 nn(1≤n≤1051\le n\le 10^5)。输入的其余部分将在交互过程中给出。

输入输出样例

  • 输入#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=10n=10 and x=4x=4.

Initially the set is: 1,2,3,4,5,6,7,8,9,10{1,2,3,4,5,6,7,8,9,10}.

In the first operation, you ask how many numbers are multiples of 44 and delete them. The answer is 22 because there are two numbers divisible by 44: 4,8{4,8}. 88 will be deleted but 44 won't, because the number xx will never be deleted. Now the set is 1,2,3,4,5,6,7,9,10{1,2,3,4,5,6,7,9,10}.

In the second operation, you ask how many numbers are multiples of 22. The answer is 44 because there are four numbers divisible by 22: 2,4,6,10{2,4,6,10}.

In the third operation, you ask how many numbers are multiples of 88. The answer is 00 because there isn't any number divisible by 88 in the current set.

In the fourth operation, you know that x=4x=4, which is the right answer.

注意:为了使样例更清晰,我们额外添加了空行。在交互过程中,你不应输出任何额外的空行。

在第一个测试中,n=10n=10 且 x=4x=4。

初始集合为:1,2,3,4,5,6,7,8,9,10{1,2,3,4,5,6,7,8,9,10}。

在第一次操作中,你询问集合中有多少个数是 44 的倍数,并将这些倍数删除。答案为 22,因为有两个数能被 44 整除:4,8{4,8}。其中 88 将被删除,但 44 不会删除,因为数 xx 永远不会被删除。此时集合变为 1,2,3,4,5,6,7,9,10{1,2,3,4,5,6,7,9,10}。

在第二次操作中,你询问集合中有多少个数是 22 的倍数。答案为 44,因为有四个数能被 22 整除:2,4,6,10{2,4,6,10}。

在第三次操作中,你询问集合中有多少个数是 88 的倍数。答案为 00,因为当前集合中没有任何数能被 88 整除。

在第四次操作中,你确定 x=4x=4,即为正确答案。

输入解题思路,AI测评打分。不知道怎么写?

首页