编程介的小学生 2017-02-13 15:10 采纳率: 20.5%
浏览 870
已采纳

Harry Potter and the Binary Kingdom

问题描述 :

After defeating the Voldemort, Harry is enjoying his senior year in Hogwarts with his friends. They decide to make a graduation trip, using their newest magical broom. In the journey, Harry is trapped in a Kingdom named Binary Kingdom, maybe because the smart but isolated people still have no idea of the great reputation of this young wizard. Loving numbers and binary very much, the subjects of Binary Kingdom claim only Harry solve the problem can he leave there.
Harry Potter and J.K.Rowling

The problem begins with an empty number multi-set, with six kinds of operation:

  1. INS M: insert M into the set
  2. DEL M: delete all numbers equal to M if any one exists; otherwise report “Del error”
  3. ADD M: increase the value of every number by M
  4. SUB M: decrease the value of every number by M if after decreasing no number will be less than zero; otherwise report “Sub error”
  5. QNUM M: query how many numbers equal to M in the set
  6. QBIT M: query how many numbers whose M-th bit is 1 in its binary, M is counting from lower to higher, beginning with 0

Though our brave Harry Potter can proficient in many fields, he is not good at math, now, it’s your time.

输入:

The first line contains a single integer T, indicating the number of test cases.
Each test case begins with an integer M, following M operations.

Technical Specification

  1. 1 <= T <= 12
  2. 1 <= M <= 100 000
  3. The QBIT operations’ M will in the range [0, 17], the other five operations’ M in the range [0, 1 000 000 000].

输出:

The first line contains a single integer T, indicating the number of test cases.
Each test case begins with an integer M, following M operations.

Technical Specification

  1. 1 <= T <= 12
  2. 1 <= M <= 100 000
  3. The QBIT operations’ M will in the range [0, 17], the other five operations’ M in the range [0, 1 000 000 000].

样例输入:

1
10
INS 1
INS 2
DEL 1
INS 3
DEL 1
ADD 1
SUB 4
QNUM 2
QBIT 1
QBIT 2
样例输出:

Case 1:
Del error
Sub error
0
1
1

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-02-19 15:45
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型