10110 - Light, more light

All about problems in Volume 101. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

New poster
Posts: 6
Joined: Thu Dec 04, 2014 11:40 pm

Re: 10110 - Light, more light

Post by This Is ERFAN »

Why getting time limit...?? Check it out plz..

Code: Select all


int main()
    long long int a,i;
        if(a==0) return 0;
        long long int temp=a;
            if(a%i==0) temp=temp*(-1);
            else continue;
        if(temp<0) printf("yes\n");
        else printf("no\n");
    return 0;

Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: Slow algorithm

Post by brianfry713 »

brianfry713 wrote:You can solve for each input value in constant time using sqrt().
Your algorithm O(n) is too slow.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 101 (10100-10199)”