标签:NPU scribe lld alac res lang and ber 一个
(Thanos)[https://open.kattis.com/problems/thanos]
Thanos
Dr. Thanos, data scientist and self-described nihilist, recently published a paper titled The snapping point of the universe: why rates of population growth point towards imminent destruction. In his paper, Thanos explains that in many planets, the increasing population count is leading to a diminished quality of life. He is convinced that his findings will drive sweeping reforms in intergalactic law, leading to a better life for all organisms.
Thanos turns to you, his confidant, to do some investigation. He would like some concrete evidence for his findings to present to the Association of VENGE’s Research Society. The society, one of the galatic leaders in egalitarianism and social justice, is holding a special panel to discuss Thano’s findings. As this involves the chance of actual legislation being passed, Thanos is convinced that the panelists are going to be a tough sell. He asks you to investigate several datasets and see if they could be potentially helpful in supporting his argument.
Thanos hands you the data for several planets. On each planet’s file, you read that: the planet currently has a population of P, its population grows by a factor of R times per year, and its annual food production F in tons. All food produced in a year must be consumed that year; it cannot be saved. Assume that each individual consumes 1 ton of food per year, and that the population for each planet each year is always counted as a whole number, rounded down. Given this information, your task is to find out the number of years a planet has remaining before its population is no longer sustainable by its food production.
Input
The first line of input consists of a single integer T (1≤T≤2000), the number of planets that need to be analyzed.
T lines follow, the ith of which consists of three space-separated integers \(P (1≤P≤10^9), R (1<R≤10^9)\), and \(F (1≤F≤10^9)\), the metrics of planet i as described above.
Output
Print T lines, the ith of which should consist of a single integer denoting the number of years the ith planet has before it is no longer sustainable.
有T组数据,每组数据给你三个数P,R, F, P每年人数增长R倍,一个人一年吃1吨食物,每年有F吨食物而且多的不能留到下一年,问你可以这个星球离毁灭还有多少年?
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll P,R,F;
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%lld%lld%lld",&P,&R,&F);
ll ans=0;
while(P<=F)
{
ans++;
P*=R;
}
printf("%lld\n",ans);
}
return 0;
}
标签:NPU scribe lld alac res lang and ber 一个
原文地址:https://www.cnblogs.com/xuwanwei/p/12880178.html