求题解
  • 板块灌水区
  • 楼主wangyuxi008
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/12/16 13:22
  • 上次更新2023/12/16 15:19:47
查看原帖
求题解
773346
wangyuxi008楼主2023/12/16 13:22

题目描述 Consider a game where there are � n children (numbered 1,2,…, � n) in a circle. During the game, every second child is removed from the circle, until there are no children left. Your task is to process � q queries of the form: “when there are � n children, who is the � kth child that will be removed?” 考虑一个游戏,其中有n个孩子(编号为 1,2,…, � n)围成一个圆圈。 在游戏过程中,每隔一个孩子就会被移出圈子,直到没有孩子留下为止。 处理 � ( 1 ≤ � ≤ 1 0 5 ) q(1≤q≤10 5 ) 个以下形式的查询:”当有 � n 个孩子时,谁是第 � k个将被移出的孩子? ( 1 ≤ � ≤ � ≤ 1 0 9 ) (1≤k≤n≤10 9 )

输入格式 第一行输入一个整数 � q:表示查询的数量。

从第二行开始分别是 � q行描述查询。每行有两个整数 � n和 � k:表示孩子的数量和第几个将被移出的孩子。

输出格式 输出 � q个整数:表示每个查询的答案。

输入输出样例 输入样例1:4 7 1 7 3 2 2 1337 1313 输出样例1:2 6 1 1107 数据范围与提示 1 ≤ � ≤ 1 0 5 1≤q≤10 5

1 ≤ � ≤ � ≤ 1 0 9 1≤k≤n≤10 9

2023/12/16 13:22
加载中...