CodeChef - Please like me 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 &lt;= T &lt;= 1000
  
  1 &lt;= L &lt;= 1000000000
  
  1 &lt;= D &lt;= 1000000000
  
  1 &lt;= S &lt;= 1000000000
  
  1 &lt;= C &lt;= 1000000000
  
  Sample cases:
  
  Input
  
  2
  
  5 1 5 1
  
  10 2 2 2
  
  Output
  
  ALIVE AND KICKING
  
  DEAD AND ROTTING


#include &lt;stdio.h&gt;

int main()
{
    int t;
    scanf("%d",&amp;t);
    while(t--)
    {
        long long int l,d,s,c;
        scanf("%lld%lld%lld%lld",&amp;l,&amp;d,&amp;s,&amp;c);
        long long int i;
        long long int x=s;
        for(i=2;i&lt;=d;i++)
            x*=(1+c);
        if(x&gt;=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?
I think the key thing you are missing isn't a better pow function.  The problem is that you are iterating d times without checking whether you have surpassed l.  Notice that for the lowest c of 1, you are multiplying by 2 every loop.  The maximum l is 1000000000 which is less than 2^30.  Therefore the max number of loops you will ever need is 30.

If you simply checked every loop:

if (x &gt;= l)
    break;


then you limit your loop to 30 iterations instead of 1000000000 iterations.