Take a look at the problem statement here .
In a far away dystopian world, the measure of the quality of a person’s life is the numbers of likes he gets for an article about their life. For a person to stay alive, he has to acquire at least L number of likes before D days pass.
People in this world employ various techniques to increase the number of likes. One of the famous ones is to dis-like and re-like their own article once per day. On doing so you can assume that the number of likes for the post increase by a constant factor C.
So if one starts with S likes on Day-1, he would have D2 = S + C * S likes on Day-2, D3 = D2 + D2 * C on Day-3 etc. You are to answer if the person would survive at the end of Day-D or not.
Input
First line contains a single positive integer T denoting the number of test cases. The following T lines represent a test case each. Each test case contains 4 space-separated integers L, D, S and C.
Output
For each test case, print a single line containing "ALIVE AND KICKING" if the person would live, otherwise print, "DEAD AND ROTTING".
Constraints
1 <= T <= 1000
1 <= L <= 1000000000
1 <= D <= 1000000000
1 <= S <= 1000000000
1 <= C <= 1000000000
Sample cases:
Input
2
5 1 5 1
10 2 2 2
Output
ALIVE AND KICKING
DEAD AND ROTTING
#include <stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long int l,d,s,c;
scanf("%lld%lld%lld%lld",&l,&d,&s,&c);
long long int i;
long long int x=s;
for(i=2;i<=d;i++)
x*=(1+c);
if(x>=l)
printf("ALIVE AND KICKING\n");
else
printf("DEAD AND ROTTING\n");
}
return 0;
}
How do I improve efficiency so that the time limit does not get exceeded?
Take a look at the problem statement here .
#include <stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long int l,d,s,c;
scanf("%lld%lld%lld%lld",&l,&d,&s,&c);
long long int i;
long long int x=s;
for(i=2;i<=d;i++)
x*=(1+c);
if(x>=l)
printf("ALIVE AND KICKING\n");
else
printf("DEAD AND ROTTING\n");
}
return 0;
}
How do I improve efficiency so that the time limit does not get exceeded?
In a far away dystopian world, the measure of the quality of a person’s life is the numbers of likes he gets for an article about their life. For a person to stay alive, he has to acquire at least L number of likes before D days pass.
People in this world employ various techniques to increase the number of likes. One of the famous ones is to dis-like and re-like their own article once per day. On doing so you can assume that the number of likes for the post increase by a constant factor C.
So if one starts with S likes on Day-1, he would have D2 = S + C * S likes on Day-2, D3 = D2 + D2 * C on Day-3 etc. You are to answer if the person would survive at the end of Day-D or not.
Input
First line contains a single positive integer T denoting the number of test cases. The following T lines represent a test case each. Each test case contains 4 space-separated integers L, D, S and C.
Output
For each test case, print a single line containing "ALIVE AND KICKING" if the person would live, otherwise print, "DEAD AND ROTTING".
Constraints
1 <= T <= 1000
1 <= L <= 1000000000
1 <= D <= 1000000000
1 <= S <= 1000000000
1 <= C <= 1000000000
Sample cases:
Input
2
5 1 5 1
10 2 2 2
Output
ALIVE AND KICKING
DEAD AND ROTTING
#include <stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long int l,d,s,c;
scanf("%lld%lld%lld%lld",&l,&d,&s,&c);
long long int i;
long long int x=s;
for(i=2;i<=d;i++)
x*=(1+c);
if(x>=l)
printf("ALIVE AND KICKING\n");
else
printf("DEAD AND ROTTING\n");
}
return 0;
}
How do I improve efficiency so that the time limit does not get exceeded?
Take a look at the problem statement here.
#include <stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long int l,d,s,c;
scanf("%lld%lld%lld%lld",&l,&d,&s,&c);
long long int i;
long long int x=s;
for(i=2;i<=d;i++)
x*=(1+c);
if(x>=l)
printf("ALIVE AND KICKING\n");
else
printf("DEAD AND ROTTING\n");
}
return 0;
}
How do I improve efficiency so that the time limit does not get exceedexceeded?
Take a look at the problem statement here.
#include <stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long int l,d,s,c;
scanf("%lld%lld%lld%lld",&l,&d,&s,&c);
long long int i;
long long int x=s;
for(i=2;i<=d;i++)
x*=(1+c);
if(x>=l)
printf("ALIVE AND KICKING\n");
else
printf("DEAD AND ROTTING\n");
}
return 0;
}
How do I improve efficiency so that the time limit does not get exceed?
Take a look at the problem statement here.
#include <stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long int l,d,s,c;
scanf("%lld%lld%lld%lld",&l,&d,&s,&c);
long long int i;
long long int x=s;
for(i=2;i<=d;i++)
x*=(1+c);
if(x>=l)
printf("ALIVE AND KICKING\n");
else
printf("DEAD AND ROTTING\n");
}
return 0;
}
How do I improve efficiency so that the time limit does not get exceeded?
Take a look at the problem statement here.
Here is my code.
#include <stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long int l,d,s,c;
scanf("%lld%lld%lld%lld",&l,&d,&s,&c);
long long int i;
long long int x=s;
for(i=2;i<=d;i++)
x*=(1+c);
if(x>=l)
printf("ALIVE AND KICKING\n");
else
printf("DEAD AND ROTTING\n");
}
return 0;
}
How do I improve efficiency so that the time limit does not get exceed?
Take a look at the problem statement here.
Here is my code.
#include <stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long int l,d,s,c;
scanf("%lld%lld%lld%lld",&l,&d,&s,&c);
long long int i;
long long int x=s;
for(i=2;i<=d;i++)
x*=(1+c);
if(x>=l)
printf("ALIVE AND KICKING\n");
else
printf("DEAD AND ROTTING\n");
}
return 0;
}
How do I improve efficiency so that time limit does not exceed?
Take a look at the problem statement here.
#include <stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long int l,d,s,c;
scanf("%lld%lld%lld%lld",&l,&d,&s,&c);
long long int i;
long long int x=s;
for(i=2;i<=d;i++)
x*=(1+c);
if(x>=l)
printf("ALIVE AND KICKING\n");
else
printf("DEAD AND ROTTING\n");
}
return 0;
}
How do I improve efficiency so that the time limit does not get exceed?