HBC51484MonsterHunter,二分,分治,思维generator 2题解

凯凯我们等你回来 算法基础篇 49 0
想要成为编程高手?那就来试试全网最全C++题库,让您在练习中快速成长。
. Please answer Q queries. Each query consists of one integer v, asking the minimum index i such that. =v. If the sequence doesn't have any number with value v, you only need to output -1.The value of n may be as large as. Because n is so large. We will only give you four integers. ,a,b,p to generate the sequence. For all i>0, the sequence is generated as

There is a sequence of length n: x_0, x_1, x_2, ldots, x_{n-1} x ​ ,x 1 ​ ,x 2 ​ ,…,x n−1 ​ . Please answer Q queries. Each query consists of one integer v, asking the minimum index i such that x_i = v x i ​ =v. If the sequence doesn't have any number with value v, you only need to output -1. Does the problem look simple? Surprise! The value of n may be as large as 10^{18} 10 18 ! Because n is so large. We will only give you four integers x_0, a, b, p x ​ ,a,b,p to generate the sequence. For all i>0, the sequence is generated as x_i = (a cdot x_{i-1} + b) mod p x i ​ =(a⋅x i−1 ​ +b)modp.

HBC51484MonsterHunter,二分,分治,思维generator 2题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
成为编程大师,不再是梦想!全网最全C++题库,助您开启编程新篇章。

标签: HBC51484MonsterHunter 二分 分治 思维generator 2题解