描述
姚博士参与了关于复发功能的性质的主题的秘密研究。本研究中的一些功能是以下模式:
\ begin {tabular} {ll} \ textit {f}(\ textit {j})= \ textit {a} $ _ j $&for 1 $ \ le $ \ textit {j} $ <$ \ textit {d}
\\ \ emph {f}(\ emph {d} $ \ times $ \ emph {n} + \ emph {j})= d $ \ times $ f(\ textit {n})+ \ textit {b} $
_j $&for 0 $ \ le $ \ textit {j} $ <$ \ textit {d}和\ textit {n} $ \ ge $ 1,\\ \ end {tabular}
其中集合{ai} = {1,2,...,d-1}和{bi} = {0,1,...,d-1}。
我们表示:
\ begin {tabular} {l} \ emph {f} $ _ x $(\ emph {m})= \ emph {f}(\ emph {f}(\ emph {f}($ \ cdots $ \ emph {f
}(\ emph {m}))))\ quad \ emph {x} times \\ \ end {tabular}
姚的问题是,给定两个正整数m和k,你能找到一个最小的非负整数x
\ begin {tabular} {l} \ emph {f} $ _ x $(\ emph {m})= \ emph {k} \\ \ end {tabular}
输入
有几个测试用例。每个测试用例的第一行包含整数d(2≤d≤100)。第二行包含2d-1个整数:a1,...,ad-1,后跟b0,...,bd-1。第三行包含整数m(0
<m≤10100),第四行包含整数k(0 <k≤10100)。输入文件以整数-1结尾。
输出
对于每个测试用例,如果它存在这样一个整数x,输出最小的。我们保证答案小于263.否则输出一个字“NO”。
POJ 3708 Recurrent Function 已翻译
最新推荐文章于 2020-05-24 11:32:47 发布