编程介的小学生 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
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度