CF198A.About Bacteria
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Qwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some experiments on bacteria that have funny and abnormal properties. The job isn't difficult, but the salary is high.
At the beginning of the first experiment there is a single bacterium in the test tube. Every second each bacterium in the test tube divides itself into k bacteria. After that some abnormal effects create b more bacteria in the test tube. Thus, if at the beginning of some second the test tube had x bacteria, then at the end of the second it will have kx + b bacteria.
The experiment showed that after n seconds there were exactly z bacteria and the experiment ended at this point.
For the second experiment Qwerty is going to sterilize the test tube and put there t bacteria. He hasn't started the experiment yet but he already wonders, how many seconds he will need to grow at least z bacteria. The ranger thinks that the bacteria will divide by the same rule as in the first experiment.
Help Qwerty and find the minimum number of seconds needed to get a tube with at least z bacteria in the second experiment.
Qwerty 这位巡警接受了政府工作,抵达了火星。他需待在秘密实验室中,对一类具有奇特且反常性质的细菌开展若干实验。这项工作并不困难,但薪酬很高。
在第一次实验开始时,试管中仅有 1 个细菌。此后,每过一秒,试管中的每个细菌都会分裂为 k 个细菌;紧接着,某些反常效应又会在试管中额外产生 b 个细菌。因此,若在某秒初试管中有 x 个细菌,则在该秒末试管中将有 kx+b 个细菌。
实验结果表明:经过 n 秒后,试管中恰好有 z 个细菌,此时实验即告结束。
在第二次实验中,Qwerty 将对试管进行灭菌处理,并放入 t 个细菌。他尚未启动该实验,却已好奇:需要多少秒才能使试管中的细菌数量至少达到 z?这位巡警认为,细菌的增殖规律与第一次实验完全相同。
请帮助 Qwerty 求出:在第二次实验中,使试管内细菌数至少达到 z 所需的最短时间(以秒为单位)。
输入格式
The first line contains four space-separated integers k, b, n and t (1 ≤ k, b, n, t ≤ 106) — the parameters of bacterial growth, the time Qwerty needed to grow z bacteria in the first experiment and the initial number of bacteria in the second experiment, correspondingly.
第一行包含四个以空格分隔的整数 k、b、n 和 t(1 ≤ k, b, n, t ≤ 106),分别表示细菌增长的参数、Qwerty 在第一次实验中培养 z 个细菌所需的时间,以及第二次实验中细菌的初始数量。
输出格式
Print a single number — the minimum number of seconds Qwerty needs to grow at least z bacteria in the tube.
输出一个整数——Qwerty 在试管中培养至少 z 个细菌所需的最少秒数。
输入输出样例
输入#1
3 1 3 5
输出#1
2
输入#2
1 4 4 7
输出#2
3
输入#3
2 2 4 100
输出#3
0
输入解题思路,AI测评打分。不知道怎么写?