3072: 【普及+/提高】【P1069】细胞分裂

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:0 解决:0

题目描述

Hanks 博士是 BT(Bio-Tech,生物技术)领域的知名专家。现在,他正在为一个细胞实验做准备工作:培养细胞样本。

Hanks 博士手里现在有 lns="http://www.w3.org/1998/Math/MathML"> 种细胞,编号从 lns="http://www.w3.org/1998/Math/MathML">1,一个第 lns="http://www.w3.org/1998/Math/MathML"> 种细胞经过 lns="http://www.w3.org/1998/Math/MathML">1 秒钟可以分裂为 lns="http://www.w3.org/1998/Math/MathML"> 个同种细胞(lns="http://www.w3.org/1998/Math/MathML"> 为正整数)。现在他需要选取某种细胞的一个放进培养皿,让其自由分裂,进行培养。一段时间以后,再把培养皿中的所有细胞平均分入 lns="http://www.w3.org/1998/Math/MathML"> 个试管,形成 lns="http://www.w3.org/1998/Math/MathML"> 份样本,用于实验。Hanks 博士的试管数 lns="http://www.w3.org/1998/Math/MathML"> 很大,普通的计算机的基本数据类型无法存储这样大的 lns="http://www.w3.org/1998/Math/MathML"> 值,但万幸的是,lns="http://www.w3.org/1998/Math/MathML"> 总可以表示为 lns="http://www.w3.org/1998/Math/MathML">1 的 lns="http://www.w3.org/1998/Math/MathML">2 次方,即 lns="http://www.w3.org/1998/Math/MathML">=12,其中 lns="http://www.w3.org/1998/Math/MathML">1,2 均为基本数据类型可以存储的正整数。

注意,整个实验过程中不允许分割单个细胞,比如某个时刻若培养皿中有 lns="http://www.w3.org/1998/Math/MathML">4 个细胞,Hanks 博士可以把它们分入 lns="http://www.w3.org/1998/Math/MathML">2 个试管,每试管内 lns="http://www.w3.org/1998/Math/MathML">2 个,然后开始实验。但如果培养皿中有 lns="http://www.w3.org/1998/Math/MathML">5 个细胞,博士就无法将它们均分入 lns="http://www.w3.org/1998/Math/MathML">2 个试管。此时,博士就只能等待一段时间,让细胞们继续分裂,使得其个数可以均分,或是干脆改换另一种细胞培养。

为了能让实验尽早开始,Hanks 博士在选定一种细胞开始培养后,总是在得到的细胞“刚好可以平均分入 lns="http://www.w3.org/1998/Math/MathML">

 个试管”时停止细胞培养并开始实验。现在博士希望知道,选择哪种细胞培养,可以使得实验的开始时间最早。

【输入输出样例 #1 说明】

经过 lns="http://www.w3.org/1998/Math/MathML">1 秒钟,细胞分裂成 lns="http://www.w3.org/1998/Math/MathML">3 个,经过 lns="http://www.w3.org/1998/Math/MathML">2 秒钟,细胞分裂成 lns="http://www.w3.org/1998/Math/MathML">9个,……,可以看出无论怎么分裂,细胞的个数都是奇数,因此永远不能分入 lns="http://www.w3.org/1998/Math/MathML">2 个试管。

【输入输出样例 #2 说明】

第 lns="http://www.w3.org/1998/Math/MathML">1 种细胞最早在 lns="http://www.w3.org/1998/Math/MathML">3 秒后才能均分入 lns="http://www.w3.org/1998/Math/MathML">24 个试管,而第 lns="http://www.w3.org/1998/Math/MathML">2 种最早在 lns="http://www.w3.org/1998/Math/MathML">2 秒后就可以均分(每试管 lns="http://www.w3.org/1998/Math/MathML">144/241=6 个)。故实验最早可以在 lns="http://www.w3.org/1998/Math/MathML">2 秒后开始。

【数据范围】

对于 lns="http://www.w3.org/1998/Math/MathML">50% 的数据,有 lns="http://www.w3.org/1998/Math/MathML">1230000

对于所有的数据,有 lns="http://www.w3.org/1998/Math/MathML">110000lns="http://www.w3.org/1998/Math/MathML">1130000lns="http://www.w3.org/1998/Math/MathML">1210000lns="http://www.w3.org/1998/Math/MathML">12×109

NOIP 2009 普及组 第三题

输入

第一行,有一个正整数 lns="http://www.w3.org/1998/Math/MathML">,代表细胞种数。

第二行,有两个正整数 lns="http://www.w3.org/1998/Math/MathML">1,2,以一个空格隔开,即表示试管的总数 lns="http://www.w3.org/1998/Math/MathML">=12

第三行有 lns="http://www.w3.org/1998/Math/MathML"> 个正整数,第 lns="http://www.w3.org/1998/Math/MathML"> 个数 lns="http://www.w3.org/1998/Math/MathML"> 表示第 lns="http://www.w3.org/1998/Math/MathML"> 种细胞经过 lns="http://www.w3.org/1998/Math/MathML">1 秒钟可以分裂成同种细胞的个数。

输出

一个整数,表示从开始培养细胞到实验能够开始所经过的最少时间(单位为秒)。

如果无论 Hanks 博士选择哪种细胞都不能满足要求,则输出整数 lns="http://www.w3.org/1998/Math/MathML">1

样例输入 复制

1 
2 1 
3

样例输出 复制

-1