Saturday, 18 July 2015

BEENUMS

Standard

Beehive Numbers

Link to the question : BEENUMS 

HINT :

The question may be a bit lengthy and also it might be difficult for us to imagine a beehive following the norms as per the question. But we dont have to worry about that. All we need to observe is the pattern in given example and VOILA our question is solved. 


RECOMMENDED QUESTION :

Try your hands in this question.

SOURCE CODE :

#include<stdio.h>
#include<math.h>
int main()
{
    long long int n,x=1,y;
    double t;
    while(x!=-1)
    {
        scanf("%lld",&n);
        x=n;
        if(x!=-1)
        {
            if(n%6==1)
            {
                  t= sqrt(1+ (4*(n-1)/3));
                  y= (int)(t*10);
                  if(y==t*10)
                    printf("Y\n");
                  else
                    printf("N\n");
            }
            else
            printf("N\n");
        }
    }
    return 0;
}

0 comments:

Post a Comment