编程介的小学生 2018-12-03 06:24 采纳率: 20.5%
浏览 362
已采纳

一个二叉树的遍历方面的问题求问下各位大神了

Problem Description
ZY found a weird segment tree with range [1, n].
For one node a, b we choose a random integer x in range [a, b), seperate the segment into [a,x] and [x+1,b].
While doing query on this segment tree, bad thing happens. For one query [l, r]. If we want to obtain the information of the range [l, r], what is the expected number of nodes in the segment tree that would be visited?
For example, when querying range [2,4] in this segment tree, we will visit nodes in red.

Input
The first line contains two integer n,q.
The following q lines each contain a query interval [l,r].
1≤n,q≤106.

Output
For each query, output the expected number of visited nodes in a line, modulo 998244353.

Sample Input
2 3
1 1
2 2
1 2

Sample Output
2
2
1

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-03-14 00:18
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏