AVLVKT - Lovely Kitty Solution or Editorial SPOJ - UCS - Unleash-Coding-Skills

Wednesday, 1 August 2018

AVLVKT - Lovely Kitty Solution or Editorial SPOJ - UCS


This is a link for  AVLVKT - Lovely Kitty  in spoj is:


https://www.spoj.com/problems/AVLVKT/

We are just considering the clock starting at 1'O clock that means that minutes hand and hours hand starts at that point. For every hour we are calculating the exact position of hours hand relative to the hour's hand by formula's.

 h=j*30; // the start position of hours hand at beginning of that hour in code
 m=k*6; // the position of the minute's hand  in code
 h=h+k*0.5; // the position of the hour's hand with respect to the minute's hand

Here 'h' stands for hours hand and 'm' stands for minutes hand. In code, the variable, 're' used of difference between the angle of hour's and minute's hand.




The C solution for AVLVKT - Lovely Kitty is:

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

int main() {
    int t,i;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
       float a,h,m,re;
       int j,k,c=0;
       scanf("%f",&a);
       for(j=1;j<=12;j++)
       {
           for(k=0;k<60;k++)
           {
               h=j*30;
               m=k*6;
               h=h+k*0.5;
               re=fabsf(h-m);
               if(re>180)
               re=re-180;
               if(a==re)
               {
                   c++;        
               }
               
           }
       }
       printf("Case %d: %d\n",i+1,c);
    }
    return 0;

}

Happy Coding.......

Tags:

AVLVKT,  Lovely Kitty, AVLVKT - Lovely Kitty Solution, AVLVKT - Lovely Kitty Editorial, AVLVKT - Lovely Kitty answer, AVLVKT - Lovely Kitty Solution or Editorial  spoj, AVLVKT - Lovely Kitty Solution spoj, AVLVKT - Lovely Kitty  Editorial spoj, AVLVKT - Lovely Kitty spoj,
spoj solution for AVLVKT - Lovely Kitty 

1 comment:

  1. Poor.

    So what's the angle between the hands at 00:00? Here's a clue, it's less than the 180 degrees your code reports.

    ReplyDelete