#Lutece3229. 米奇妙妙程序
米奇妙妙程序
Migrated from Lutece 3229 米奇妙妙程序
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
初始一个长为 的序列 ,下标从 开始,所有元素均为 。且有变量 ,初值为 。
现执行以下操作 次:
- 从 中等概率选取一个值,记为 。
- 若 ,则置 为 1,否则:
- 从 中等概率选取一个值,记为 。
- 若 ,则找到最小的 ,满足 且 ; 若 ,则找到最大的 ,满足 且 。
- 若 存在,置 ; 否则,置 。
求 在模 意义下的结果。
Input
本题采用多测,第一行,一个正整数 ,表示数据组数
对于每组数据,一行,两个正整数 和 。
Output
对于每组数据,一行,一个整数,表示答案。
Samples
Constraints
,
Resources
2024 UESTC ICPC Training for Math