Sunday 24 August 2014

In love with codes

These days I am truly enjoying programming . Learning new & exciting techniques/algorithms .

Now,I've started challenging  my friends to see who is better at competitive programming . This week I participated in codeforces Div2 round and solved 1 problem but I lost to my friend Sudharsan who got it correct in first go and that too within 14 minutes , that's very impressive start but I don't like to lose much and I'll come back strong .

These days I am solving problems on codeforces .

Surprisingly we(me & Sudharsan) got selected for round 2 of TCS coding contest and will try to best in the second round as we couldn't do well in our first round .

Last night I was solving a problem which required factors of a no. to be calculated first . I was thinking of searching the method on the net but then I decided that I'll try it out myself first . I came with an idea and it worked

Suppose we want to calculate factors of N (including 1 & N itself)
for(i=1;i<=sqrt(N);i++)
{
     if(i*(N/i)==N)
    {  
        printf("%d",i);
        if(i!=N/i)
        printf("%d",i);
     }
}
This will print all the factors of N . If statement is included to avoid repetition of 1 if we write N = 1.

Today I've challenged my friends in Codechef's Cook off . Lets see who wins . Waiting for the round to commence .

Thanks for reading and keep coding .

No comments:

Post a Comment