ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1131. Copying

#include<stdio.h>
#include<math.h>

int main()
{
    int n,k,i=1,s=1,t=0,temp=0;
    scanf("%d %d",&n,&k);

    while(i<k)
    {
        s=s+i;
        i=2*i;
        t++;

        if(s>=n)
            break;
    }
    while(s<n)
    {
        s=s+k;
        t++;
    }

    printf("%d",t);
    return 0;
}
ToadMonster Re: time exceeded。。can you help me make it faster? [1] // Problem 1131. Copying 23 Sep 2016 16:30
    while(s<n)
    {
        s=s+k;
        t++;
    }

Isn't here (n-s)/k iterations?
#pragma optimize( "g", on )