Atoms in the Lab
Link to the question : ATOMS
HINT :
At every second,a single atom breaks into k atoms. Hence if there are n atoms at time t, then at time t+1 there will be n*k atoms. Since, there is a limit given to the maximum number of atoms m, we need to check if n*k is smaller than m and thereby also keep counting the time.
SOURCE CODE :
#include<stdio.h>
int main()
{
int p;
scanf("%d",&p);
while(p--)
{
unsigned long long int n,k,m,s=1,t=0;
scanf("%llu%llu%llu",&n,&k,&m);
if(n>m)
printf("0\n");
else
{
while(s<=m/n)
{
s=s*k;
if(s<=m/n)
t++;
}
printf("%llu\n",t);
}
}
return 0;
}
Sometime few educational blogs become very helpful while getting relevant and new information related to your targeted area. As I found this blog and appreciate the information delivered to my database.
ReplyDeleteapron